compare between two unequal vectors

5 ビュー (過去 30 日間)
jojototo
jojototo 2017 年 8 月 15 日
コメント済み: jojototo 2017 年 8 月 16 日
Hi all,If A=[2,3,4,5,6] and B=[2,3,4,6] I want to compare the first element in A with all elements in B if existed the output is 1 if not so the output is 0,and so the second , the third,the fourth and the fifth element in A with all elements in B finally the output is C=1 1 1 0 1
  1 件のコメント
José-Luis
José-Luis 2017 年 8 月 15 日
I don't understand how you get to your final output. The way you describe it your result should be a 5x4 array.
C can be computed with ismember().

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

採用された回答

José-Luis
José-Luis 2017 年 8 月 15 日
A = [2,3,4,5,6];
B = [2,3,4,6];
dummy = bsxfun(@eq, A',B)
dummier = ismember(A,B)
  1 件のコメント
jojototo
jojototo 2017 年 8 月 16 日
Thanks, it works

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

その他の回答 (0 件)

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by