sorting 2 array based on elements of other array

2 Ansichten (letzte 30 Tage)
Niharika  Nayak
Niharika Nayak am 3 Jan. 2020
Beantwortet: Vladimir Sovkov am 3 Jan. 2020
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

Akzeptierte Antwort

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

Weitere Antworten (0)

Kategorien

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

Community Treasure Hunt

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

Start Hunting!

Translated by