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

4 visualizaciones (últimos 30 días)
Gamma1990
Gamma1990 el 4 de Jul. de 2021
Comentada: Gamma1990 el 4 de Jul. de 2021
列ベクトルが下のようなときについて質問です.
A=
1
2
3
2
このとき,行列Aの成分を上から大きい順に入れ替えた行列Bに変換して,
B=
3
2
2
1
としたいのですが,どのように実装すればよいのでしょうか?
よろしくお願いします.

Respuesta aceptada

Hernia Baby
Hernia Baby el 4 de Jul. de 2021
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 comentario
Gamma1990
Gamma1990 el 4 de Jul. de 2021
ご回答ありがとうございます.大変参考になりました.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Shifting and Sorting Matrices en Help Center y File Exchange.

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!