i have matrix
a = 1 1 1 2 2 2 3 3 3 4 4 4 5 5 5 i have 3 arrays containing orders in separately want sort respective columns. example i1 column 1, i2 column 2, ....
i1 = 5 i2 = 4 i3 = 3 4 3 2 3 2 1 2 1 5 1 5 4 after sorting matrix should get:- if i1 used sort 1st column
a = 5 1 1 4 2 2 3 3 3 2 4 4 1 5 5 if i2 used sort 2nd column
a = 1 4 1 2 3 2 3 2 3 4 1 4 5 5 5 if i3 used sort 3rd column
a = 1 1 3 2 2 2 3 3 1 4 4 5 5 5 4 if i1,i2,i3 used sort columns
a = 5 4 3 4 3 2 3 2 1 2 1 5 1 5 4 please suggest me how do.
if dimensions same, should need:
a([i1 i2 i3]); if wish sort columns individually, can use syntax:
a(:,2)=a(i2,2); or e.g. columns 2 , 3:
a(:,[2 3]) = [a(i2,2) a(i3,3)];
Comments
Post a Comment