how can i find a special row
Ältere Kommentare anzeigen
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]
Akzeptierte Antwort
Weitere Antworten (1)
Roger Stafford
am 6 Jun. 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 Kommentare
Light
am 7 Jun. 2013
Walter Roberson
am 7 Jun. 2013
rows = find( sum(A == -1, 2) == 1 );
Kategorien
Mehr zu Linear Algebra finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!