列ベクトルの成分を上​から大きい順に変える​ことはできますか?

1 次查看(过去 30 天)
Gamma1990
Gamma1990 2021-7-4
评论: Gamma1990 2021-7-4
列ベクトルが下のようなときについて質問です.
A=
1
2
3
2
このとき,行列Aの成分を上から大きい順に入れ替えた行列Bに変換して,
B=
3
2
2
1
としたいのですが,どのように実装すればよいのでしょうか?
よろしくお願いします.

采纳的回答

Hernia Baby
Hernia Baby 2021-7-4
sortの'descend'オプションで解決します。
a = [1 2 2 3]
a = 1×4
1 2 2 3
b = sort(a,'descend')
b = 1×4
3 2 2 1
  1 个评论
Gamma1990
Gamma1990 2021-7-4
ご回答ありがとうございます.大変参考になりました.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Shifting and Sorting Matrices 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!