Deleting a row y from a matrix
古いコメントを表示
If I have a matrix A and I want to delete all the rows, y, in A such that y=[1 2 3];
Ex:
A=[ 1 2 3; 4 5 6; 7 8 9; 1 2 3]; y=[1 2 3];
I want to remove all the y vectors from A so that I have:
A=[4 5 6; 7 8 9];
回答 (1 件)
JESUS DAVID ARIZA ROYETH
2020 年 2 月 17 日
編集済み: JESUS DAVID ARIZA ROYETH
2020 年 2 月 17 日
A(all(A==y,2),:)=[]
edit previous versions:
A(all(A==repmat(y,size(A,1),1),2),:)=[]
6 件のコメント
Cantor Set
2020 年 2 月 17 日
JESUS DAVID ARIZA ROYETH
2020 年 2 月 17 日
編集済み: JESUS DAVID ARIZA ROYETH
2020 年 2 月 17 日
it work for me, what is your Matlab Version?
A=[ 1 2 3; 4 5 6; 7 8 9; 1 2 3]; y=[1 2 3];
A(all(A==y,2),:)=[]
Show any error?
Cantor Set
2020 年 2 月 17 日
JESUS DAVID ARIZA ROYETH
2020 年 2 月 17 日
what does this show?
Cantor Set
2020 年 2 月 17 日
JESUS DAVID ARIZA ROYETH
2020 年 2 月 17 日
try now:
A=[ 1 2 3; 4 5 6; 7 8 9; 1 2 3]; y=[1 2 3];
A(all(A==repmat(y,size(A,1),1),2),:)=[]
カテゴリ
ヘルプ センター および File Exchange で Loops and Conditional Statements についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!