How can I check if row matrix B is equal to a row of matrix A?
14 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
laurie
am 9 Mär. 2015
Kommentiert: Star Strider
am 9 Mär. 2015
I have a matrix A = [1 2 3; 4 5 6; 7 8 9]
I randomly generate matrix B = [4 5 6]
How can I check if B is a row of A in ONE loop or using NO loops?
0 Kommentare
Akzeptierte Antwort
Star Strider
am 9 Mär. 2015
Look Laurie! NO LOOPS!
A = [1 2 3; 4 5 6; 7 8 9];
B = [4 5 6];
[Result,LocResult] = ismember(B,A,'rows')
produces:
Result =
1
LocResult =
2
The ‘Result’ output indicates that there is a match, and ‘LocResult’ that the match is the second row.
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!