How to extract parts of an array by given logical conditions?
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Emerson De Souza
le 9 Juin 2014
Commenté : Emerson De Souza
le 9 Juin 2014
Hi, I have an array, let's say
M=
1 1 0
1 2 0
1 3 1
2 1 0
2 2 1
2 3 1
and I would like to create a new array only with the case for which the value of the third column equals 1. Thus
N=
1 3 1
2 2 1
2 3 1
0 commentaires
Réponse acceptée
Image Analyst
le 9 Juin 2014
Try this:
M=[...
1 1 0
1 2 0
1 3 1
2 1 0
2 2 1
2 3 1]
rowsToExtract = M(:,3)==1;
N = M(rowsToExtract,:)
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Data Distribution Plots 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!