行列データのある列を​並べ替え、その並べ替​えた列に合わせて他の​列の位置を変える方法​を教えてください。

13 vues (au cours des 30 derniers jours)
MathWorks Support Team
MathWorks Support Team le 25 Oct 2013
下図の様に、行列データのある列を並べ替え(ソート)、その並べ替えた列に合わせて他の列の位置を変える方法を教えてください。

Réponse acceptée

MathWorks Support Team
MathWorks Support Team le 25 Oct 2013
sort関数で行なうことができます。
A=[1 3 4;3 2 9;21 5 5;10 1 2;0 10 8]
[Y,I] = sort(A(:,2))
A=A(I,:)
[Y,I] = sort(A)
Yは、Aを昇順に並べ替えた結果になります。
Iはインデックス番号になります。

Plus de réponses (0)

Catégories

En savoir plus sur Shifting and Sorting Matrices dans Help Center et File Exchange

Tags

Aucun tag saisi pour le moment.

Produits


Version

R2008a

Community Treasure Hunt

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

Start Hunting!