how can i find a special row
Afficher commentaires plus anciens
How can i find a row which including only -1. In that A matrix how can i write a code
A=[-1,-1,0,0,0;0,0,0,-1,0;0,1,-1,0,-1;0,0,1,0,0;1,0,0,1,1]
Réponse acceptée
Plus de réponses (1)
Roger Stafford
le 6 Juin 2013
I am guessing that you mean, how can you find those rows each of which includes at least one -1. Is that what you mean? If so, do this:
f = find(any(A==-1,2));
3 commentaires
Light
le 7 Juin 2013
Walter Roberson
le 7 Juin 2013
rows = find( sum(A == -1, 2) == 1 );
Catégories
En savoir plus sur Matrix Indexing 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!