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)

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Data Type Conversion에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by