Deleting a row y from a matrix

2 visualizaciones (últimos 30 días)
Cantor Set
Cantor Set el 17 de Feb. de 2020
Comentada: JESUS DAVID ARIZA ROYETH el 17 de Feb. de 2020
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];

Respuestas (1)

JESUS DAVID ARIZA ROYETH
JESUS DAVID ARIZA ROYETH el 17 de Feb. de 2020
Editada: JESUS DAVID ARIZA ROYETH el 17 de Feb. de 2020
A(all(A==y,2),:)=[]
edit previous versions:
A(all(A==repmat(y,size(A,1),1),2),:)=[]
  6 comentarios
Cantor Set
Cantor Set el 17 de Feb. de 2020
Error using ==
Matrix dimensions must agree.
JESUS DAVID ARIZA ROYETH
JESUS DAVID ARIZA ROYETH el 17 de Feb. de 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),:)=[]

Iniciar sesión para comentar.

Categorías

Más información sobre Loops and Conditional Statements 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!

Translated by