unsort.m
来自「计量工具箱」· M 代码 · 共 31 行
M
31 行
function out = unsort(xsorted,xindex)% PURPOSE: takes a sorted vector (or matrix) and sort index as input% and returns the vector (or matrix) in original unsorted form% --------------------------------------------------% USAGE: x = unsort(xsorted,xindex)% where: xsorted = a vector created with:% [xsorted xindex] = sort(x);% xindex = the vector returned from sort()% NOTE: xindex can't be a matrix% -------------------------------------------------% RETURNS: x that was input to the sort() function% --------------------------------------------------if nargin == 2[n k] = size(xsorted);[nchk kchk] = size(xindex); if nchk ~= n error('unsort: inputs are different size'); elseif kchk ~= 1 error('unsort: index must be a vector'); end;out = zeros(n,k);for i=1:nout(xindex(i,1),:) = xsorted(i,:);end;elseerror('unsort: Wrong # of input arguments');end;
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?