Sorting matrix

4 Ansichten (letzte 30 Tage)
FIR
FIR am 18 Feb. 2012
Bearbeitet: Cedric am 15 Okt. 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]

Akzeptierte Antwort

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

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Shifting and Sorting Matrices finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by