フィルターのクリア

Hot to find the matched values between two vectors and also related indeces

52 ビュー (過去 30 日間)
Juster
Juster 2012 年 6 月 17 日
Good evening to all,
I have two vectors, for example:
a = [0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27]; b= [0 8 17 25];
what I would find are the indices related the vector 'a' with the same value of 'b'...like for example in this case 1 9 18 26.
Thanks in advance.

採用された回答

Juster
Juster 2012 年 6 月 18 日
Any answer please?
Thanks
  3 件のコメント
Jan
Jan 2012 年 6 月 18 日
Look for Bruno's "ismemberf" in the FEX.
Juster
Juster 2012 年 6 月 20 日
Hello Jam, I solved thanks to the 'ismemberf' function.
Best regards.

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

その他の回答 (2 件)

Andrei Bobrov
Andrei Bobrov 2012 年 6 月 17 日
[idx,loc] = ismember(b,a);
out = loc(idx);
ADD after Knot's answer
out = find(any(abs(bsxfun(@minus,a,b.')) < eps(100)));
  1 件のコメント
Juster
Juster 2012 年 6 月 18 日
Hi Andrei I send you a personal message.
Thanks

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


Juster
Juster 2012 年 6 月 17 日
I tried it but with microsecond order it did'n work.
In fact if you try with :
a = [0:10e-6:280e-6]; b = [0 80e-6 170e-6 250e-6]; [idx,loc] = ismember(b,a); out = loc(idx);
I don't got the right values of indices.

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by