Could anyone help me how to rearrange the matrix in the descending order with respect to the values in another matrix.

조회 수: 3 (최근 30일)
I having two matrices a and b
a=[ 0.0067;
1.8509;
0.0018;
0.0008;
0.0003;
0.1866;
0.0057;
0.0010;
0.0020;
0.0060;
0.0001;
0.3758]
b=[1;
2;
3;
4;
5;
6;
7;
8;
9;
10;
11;
12]
when i used the command
c=sort(a,'descend')
i get the following result
c=[ 1.8509;
0.3758;
0.1866;
0.0067;
0.0060;
0.0057;
0.0020;
0.0018;
0.0010;
0.0008;
0.0003;
0.0001]
Based on c the b matrix needs to be rearranged in descending order in the foll0wing manner.
b=[2;
12;
6;
1;
10;
7;
9;
3;
8;
4;
5;
11]
Could anyone please help me on this.

채택된 답변

Bhaskar R
Bhaskar R 2019년 12월 3일
[~, b] = sort(c, 'descend');

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by