行列データのある列を並べ替え、その並べ替えた列に合わせて他の列の位置を変える方法を教えてください。
14 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
MathWorks Support Team
el 25 de Oct. de 2013
Respondida: MathWorks Support Team
el 25 de Oct. de 2013
下図の様に、行列データのある列を並べ替え(ソート)、その並べ替えた列に合わせて他の列の位置を変える方法を教えてください。

Respuesta aceptada
MathWorks Support Team
el 25 de Oct. de 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はインデックス番号になります。
0 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Shifting and Sorting Matrices en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!