MATLAB: Make a matrix with matching numbers per column from a bigger one

matrixmatrix array

Hello,
Suppose i have the following matrix;
A=[2011 1 2 1 101 0
2011 1 2 1 105 0
2011 1 5 5 108 13.8
2011 1 9 4 107 0.1
2011 1 18 5 101 0
2011 1 19 5 107 0.6
2011 1 21 5 101 0.9
2011 1 23 5 104 5.4
2011 1 24 5 102 4.1
2011 1 25 5 101 0
2011 1 33 5 104 0
2011 1 38 5 104 2.1
2012 1 40 4 101 0
2012 1 46 5 107 0.4
2012 1 47 5 104 5.9
2012 1 49 5 102 4.3
2012 1 60 3 107 0
2012 1 66 1 104 0
2012 1 66 1 104 0]
I want to extract a matrix with matching numbers on certain columns.
For example, the values from column 1 are 2011 and simultaneously, the values from column 5 are 101. I also want to keep the other columns.
Anything would help! Thanks in advance

Best Answer

mask = A(:,1) == 2011 & A(:,5) == 101;
B = A(mask,:);