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

1 回表示 (過去 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 Center および File ExchangeState-Space Control Design and Estimation についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by