Sorting matrix

2 views (last 30 days)
FIR
FIR on 18 Feb 2012
Edited: Cedric on 15 Oct 2013
I have amatrix
A=[1 2 13;
10 1 2;
8 14 3]
I want to sort 2nd column,so the corresponding values must also change
as
A=[10 1 2;
1 2 13;
8 14 3]

Accepted Answer

Wayne King
Wayne King on 18 Feb 2012
[~,indices] = sort(A(:,2));
A = A(indices,:);
  1 Comment
FIR
FIR on 18 Feb 2012
Thanks Wayne can u answer the question in plz
http://www.mathworks.in/matlabcentral/answers/29490-error-using-cell2mat

Sign in to comment.

More Answers (0)

Categories

Find more on Shifting and Sorting Matrices in Help Center and File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!