MATLAB: Find indices of one array in another array.

arrayfindindex

I have two different sized two column arrays, like the example below:
A = [1 1; 1 2; 2 2; 2 3; 3 3; 3 4; 4 3; 4 4];
B = [1 1; 2 2; 3 3; 4 4];
Now I want to find the indices of the rows in A that are equal to B. So the answer should be:
idx_rows = [1 3 5 8]
How can I do this?
Thanks!

Best Answer

[~,idx]=setdiff(A,B,'rows');
idx_rows=setdiff(1:size(A,1),idx)