M= [1.0000 NaN NaN 0.9000 0.3000;
2.0000 14.1450 NaN 0.8500 -0.1145;
3.0000 NaN NaN NaN NaN;
4.0000 NaN NaN 1.2500 0.5000;
5.0000 18.4500 9.3507 1.6300 0.0490;
6.0000 NaN NaN NaN NaN;
7.0000 17.1600 0 0.7163 0.2791;
8.0000 13.1500 NaN 1.0000 NaN;
9.0000 NaN NaN NaN NaN]
[P,index] = sortrows(M,3)
P(isnan(P(:,3)),:) = sortrows(P(isnan(P(:,3)),:),2)
P(isnan(P(:,2)),:) = sortrows(P(isnan(P(:,2)),:),4)
P(isnan(P(:,4)),:) = sortrows(P(isnan(P(:,4)),:),5)
P = [ [1:9]' P]
6 Comments
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/663348-swiping-row-in-matrix#comment_1161998
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/663348-swiping-row-in-matrix#comment_1161998
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/663348-swiping-row-in-matrix#comment_1162013
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/663348-swiping-row-in-matrix#comment_1162013
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/663348-swiping-row-in-matrix#comment_1162033
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/663348-swiping-row-in-matrix#comment_1162033
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/663348-swiping-row-in-matrix#comment_1162038
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/663348-swiping-row-in-matrix#comment_1162038
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/663348-swiping-row-in-matrix#comment_1162153
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/663348-swiping-row-in-matrix#comment_1162153
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/663348-swiping-row-in-matrix#comment_1166028
Direct link to this comment
https://uk.mathworks.com/matlabcentral/answers/663348-swiping-row-in-matrix#comment_1166028
Sign in to comment.