Finding the indices of the elements of one array in another

1 Ansicht (letzte 30 Tage)
babak
babak am 25 Sep. 2012
i have matrix a:
1
2
3
i have matrix b:
1
2
4
and finally matrix c:
3
5
7
i 'm going to find the indices of common contents of a and b, and create a new matrix with the contents of matrix c that are in the same indices that i found between a and b, in another words 1 and two are the common contents in a and b, their indices are 1 and 2, i'm going to shape a new matrix whit the indices 1 and 2 in from matrix c, which are 3 and 5. i wrote the following code but i can not complete that:
f=find(ismember(a,b)) ind=find(f) i dont know what should i write in next steps

Akzeptierte Antwort

Thomas
Thomas am 25 Sep. 2012
f=find(ismember(a,b))
output=c(f) % members in c having index of commons in a and b

Weitere Antworten (0)

Kategorien

Mehr zu Data Types 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