find few elements in vector
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Kerim Khemraev
am 15 Nov. 2016
Kommentiert: Kerim Khemraev
am 16 Nov. 2016
Hi!
Let's assume that I have a vector y=[3 5 6 7 9] and x=[5 9] How can I get the indices of elements in 'y' that are equal to 'x' without using cycle? I mean if I had x=5 ('x' is a scalar) I would write something like y==x or find(y==x) but 'x' is a vector. Thank you in advance
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (2)
Roger Stafford
am 15 Nov. 2016
[~,ia] = intersect(y,x);
ia contains indices with respect to y of elements that lie both in y and in x.
Siehe auch
Kategorien
Mehr zu Creating and Concatenating Matrices 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!