| Description |
Replicates a previous sort operation using the permutation matrix from that previous sort. Useful for sorting multiple matrices in parallel. If no dimension argument is supplied, matchsort will operate on the first non-singleton dimension just like sort does. Second output is the permutation matrix transformed into the corresponding matrix of linear indices.
Usage: y=matchsort(x,i)
y=matchsort(x,i,dim)
[y,li]=matchsort(x,i,dim)
Example:
Sort a and then sort the elements of b,c exactly the same way.
b=1./a
c=-a
[d,i]=sort(a)
e=matchsort(b,i)
f=matchsort(c,i)
isequal(d,1./e,-f) |