Finding the indices of the elements of one array in another

1 view (last 30 days)
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

Accepted Answer

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

More Answers (0)

Categories

Find more on Matrices and Arrays in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!