how can i find a special row
Mostrar comentarios más antiguos
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]
Respuesta aceptada
Más respuestas (1)
Roger Stafford
el 6 de Jun. de 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 comentarios
Light
el 7 de Jun. de 2013
Walter Roberson
el 7 de Jun. de 2013
rows = find( sum(A == -1, 2) == 1 );
Categorías
Más información sobre Linear Algebra en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!