Filter löschen
Filter löschen

finding specific values' rows numbers in an array

1 Ansicht (letzte 30 Tage)
sermet
sermet am 29 Jun. 2015
Bearbeitet: Guillaume am 29 Jun. 2015
a=[11;4;3;99;5;6;7];
b=[4;7];
I need to find which rows in a matrix include 4,7. The answer must be 2th and 7th rows w.r.t. the solution.

Akzeptierte Antwort

Guillaume
Guillaume am 29 Jun. 2015
Bearbeitet: Guillaume am 29 Jun. 2015
Use the second return value of ismember:
[~, row] = ismember(b, a)
row will be 0 if the value in b is not found in a.

Weitere Antworten (1)

Thorsten
Thorsten am 29 Jun. 2015
Bearbeitet: Thorsten am 29 Jun. 2015
find(a==4)
find(a==7)
  1 Kommentar
sermet
sermet am 29 Jun. 2015
how can I adopt this solution as creating loop. Because arrays' rows are several hundreds.

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Matrices and 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!

Translated by