I have this vector:
t = 1: 10 % t = 1 2 3 ..10
A= [3 4 5] % a column vector
If I type:
(3 == t)
I get the result:
0 0 1 0 0 0 0 0 0 0 % it means: 1 at location equals, and 0 at others
I want to do this for vector a, meaning that it will take each element in vector A and compare and return another vector. So in this case, the result will be a 3×10 matrix.
But this line will result in an error: A==t.
Of course, I can do this by using a for loop, but I want to vectorize this operation.
what you are looking for is the function
ismember