MATLAB: Find and remove data from array that does not match 2nd array

array simplificationMATLAB

I have two arrays. Array A has data which I would like to mimimize based on the contents of array B.
For example, Array A is:
[3, 10, 100;
5, 20, 200;
7, 30, 300;
5, 40, 400;
6, 50 500]
Array B is
[6; 7]
I would like to keep only the rows of array A, which match ANY of the contents of array B:
i.e. in Column 1 of Array A, row 3 and row 5 have values which match contents in Array B (6 & 7).
Note: numbers are random, and wil not be in order
So the final result would like to be:
[7, 30, 300;
6, 50 500]

Best Answer

Use ismember():
A = [3, 10, 100;
5, 20, 200;
7, 30, 300;
5, 40, 400;
6, 50 500]
B = [6; 7]
[ia, ib] = ismember(B, A)
C = A(ib,:)