Sorting matrix

4 visualizzazioni (ultimi 30 giorni)
FIR
FIR il 18 Feb 2012
Modificato: Cedric il 15 Ott 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]

Risposta accettata

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

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Shifting and Sorting Matrices in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by