MATLAB Answers

sorting 2 array based on elements of other array

1 view (last 30 days)
I have two arrays A and B
A=[0.1639,0.2123,0.1697];
B=[c1,c2,c3];
I want sort array B according to array A
my expected output like that
A=sort(A) which gives
A=[0.1639 0.1697 0.2123]
and as per A
B should be like this
B=[c1,c3,c2];
plz help me

  0 Comments

Sign in to comment.

Accepted Answer

Vladimir Sovkov
Vladimir Sovkov on 3 Jan 2020
[A,ind]=sort(A);
B=B(ind);

  0 Comments

Sign in to comment.

More Answers (0)

Sign in to answer this question.