mizanbuet
mizanbuet

Reputation: 29

Compare two unequal column matrix in matlab without using for loop

I want to compare two columns matrix : such as

a=[1;2;2;3;4;4;5;6] 
b=[2;4;8] 

and get the output like

d=[0;1;1;0;1;1;0;0]

which is same number of rows of matrix a.

Upvotes: 2

Views: 409

Answers (1)

chaohuang
chaohuang

Reputation: 4115

ismember is exact what you need. Try:

  c=ismember(a,b)

Upvotes: 5

Related Questions