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];

Réponses (1)

JESUS DAVID ARIZA ROYETH
JESUS DAVID ARIZA ROYETH le 17 Fév 2020
Modifié(e) : JESUS DAVID ARIZA ROYETH le 17 Fév 2020

0 votes

A(all(A==y,2),:)=[]
edit previous versions:
A(all(A==repmat(y,size(A,1),1),2),:)=[]

6 commentaires

Cantor Set
Cantor Set le 17 Fév 2020
it doesn't work
JESUS DAVID ARIZA ROYETH
JESUS DAVID ARIZA ROYETH le 17 Fév 2020
Modifié(e) : JESUS DAVID ARIZA ROYETH le 17 Fév 2020
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
Cantor Set le 17 Fév 2020
2016
JESUS DAVID ARIZA ROYETH
JESUS DAVID ARIZA ROYETH le 17 Fév 2020
what does this show?
Cantor Set
Cantor Set le 17 Fév 2020
Error using ==
Matrix dimensions must agree.
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),:)=[]

Connectez-vous pour commenter.

Catégories

En savoir plus sur Loops and Conditional Statements dans Centre d'aide et File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by