フィルターのクリア

matrix transformation to make the values of second row to be lower to higher

1 回表示 (過去 30 日間)
xueqi
xueqi 2013 年 10 月 23 日
コメント済み: xueqi 2013 年 10 月 24 日
Hi fellows,
I have a matrix D=[p1,p1,p3;d1,d2,d3]. Now I want change the column orderings such that the second row of D is ordering from lower to higher value. For example, D=[0.3,0.5,0.2;0.3,-0.1,0.7]. What I want to is the new matrix to be [0.5,0.3,0.2;-0.1,0.3,0.7]. Do you know an efficient way to realize this?

採用された回答

Wayne King
Wayne King 2013 年 10 月 23 日
編集済み: Wayne King 2013 年 10 月 23 日
I'm not sure I quite understand what you're doing from your description, but
D = [0.3,0.5,0.2;0.3,-0.1,0.7];
[~,idx] = sort(D(1,:),2,'descend');
Dnew = D(:,idx);
The above gives the new matrix you want
  1 件のコメント
xueqi
xueqi 2013 年 10 月 24 日
Exacly or even better solution that I was expected.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by