Deleting a row y from a matrix
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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];
0 Kommentare
Antworten (1)
JESUS DAVID ARIZA ROYETH
am 17 Feb. 2020
Bearbeitet: JESUS DAVID ARIZA ROYETH
am 17 Feb. 2020
A(all(A==y,2),:)=[]
edit previous versions:
A(all(A==repmat(y,size(A,1),1),2),:)=[]
6 Kommentare
JESUS DAVID ARIZA ROYETH
am 17 Feb. 2020
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),:)=[]
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!