行列から条件を指定して値を取り出す
Ältere Kommentare anzeigen
以下のような行列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,:]
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu 行列および配列 finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!