MATLAB: How to compare two vectors with numbers

comparelogical?

I have a question. I have two vectors A and B, both have a bunch of numbers. A is master and B is slave. Now what I want is to search each number in A and check if it's one of numbers in B (numbers in B is unique). If a number in A is also in B, label the position of that number in A as 1, and 0 otherwise, just like a logical comparison. Is there a command or a few lines to do this? Thanks in advance.

Best Answer