Maintain shape of logical index mask
7 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Garima Sharma
le 12 Juin 2017
Commenté : Garima Sharma
le 13 Juin 2017
I have a matrix A=[1,2,3;4,5,6]. From this, I want to remove (by row), z=[1,5], to return the matrix B=[2,3;4,6]. I'm trying to use logical indexing to do this, but that returns a vector instead of the matrix B.
if true
B=A(A~=z(:,1))
end
0 commentaires
Réponse acceptée
Andrei Bobrov
le 12 Juin 2017
Modifié(e) : Andrei Bobrov
le 12 Juin 2017
Aout = A';
Aout = reshape(Aout(Aout ~= z(:)'),[],2)';
or
Aout = A';
Aout = reshape(Aout(~ismember(Aout,z)),[],2)';
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Matrices and Arrays dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!