Finding the indices of the elements of one array in another

1 回表示 (過去 30 日間)
babak
babak 2012 年 9 月 25 日
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

採用された回答

Thomas
Thomas 2012 年 9 月 25 日
f=find(ismember(a,b))
output=c(f) % members in c having index of commons in a and b
  2 件のコメント
babak
babak 2012 年 9 月 25 日
thank you tom
Sean de Wolski
Sean de Wolski 2012 年 9 月 25 日
out = c(ismember(a,b)); %skip the find!

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Types についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by