how do i find matching row from an array?
87 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
ME
am 16 Mär. 2015
Beantwortet: Star Strider
am 16 Mär. 2015
I have an array and i want to find matching elements of a variable from the array how do i do that? p = [1 2;3 1]; c = [3 1] if (p == c) doesn't seem to work and i get an error saying matrix dimentions must agree
0 Kommentare
Akzeptierte Antwort
Star Strider
am 16 Mär. 2015
Use the ismember function with the 'rows' option:
p = [1 2;3 1];
c = [3 1];
[q, idx] = ismember(c, p, 'rows');
The ‘idx’ variable contains the row of ‘p’ that matches the data in ‘c’. The ‘q’ variable tells you if there is a match somewhere (1) or not (0).
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Multidimensional Arrays 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!