Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

New to MATLAB?

Sorting matrix

Asked by FIR

FIR (view profile)

on 18 Feb 2012
Latest activity Edited by Cedric Wannaz

Cedric Wannaz (view profile)

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] 

0 Comments

FIR

FIR (view profile)

Tags

Products

No products are associated with this question.

1 Answer

Answer by Wayne King

Wayne King (view profile)

on 18 Feb 2012
Accepted answer
[~,indices] = sort(A(:,2));
A = A(indices,:);

1 Comment

FIR

FIR (view profile)

on 18 Feb 2012

Thanks Wayne can u answer the question in plz
http://www.mathworks.in/matlabcentral/answers/29490-error-using-cell2mat

Wayne King

Wayne King (view profile)

Contact us