行列から条件を指定して値を取り出す
Mostrar comentarios más antiguos
以下のような行列Aの1列目の要素が"3"である行を抽出して別の行列として定義したいのですがうまく表現できません.
次のような行列Aがあるとします.
A=
1 -66
2 -61
3 -65
3 -64
1 -66
このとき,1列目の要素が"3"である行を抜き出し,以下のような行列Bとしたいです.
B=
3 -65
3 -64
----------------------------------------------------------------------------------------------------------------------
%Aの1行目が3である行を抽出しBとする
A=[1 -66 ; 2 -61 ; 3 -65 ; 3 -64 ; 1 -66];
B=A[A[:,1].==3,:]
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre 行列および配列 en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!