MATLAB: How to filter rows

filterationmatricesrows

I have a matrix like this
1 2 3 4 5 6 7 8
2 3 4 1 2 3 4 5
1 2 3 4 1 1 1 1
1 2 3 5 4 2 2 1
I want to separate those rows having first four entries as 1 2 3 4, as in above case I separate out row 1 and row three.

Best Answer

Probably not the most efficient way, but this works
b = a(a(:,1)==1 & a(:,2) == 2 & a(:,3) == 3 & a(:,4) == 4,:)
Where a is the name of your matrix