MATLAB: How to write an If() AND() function in MATLAB

if statementMATLAB

Hi,
I was wondering what the best way to write an IF() AND() function is. For example if I have the following information, I want to select the values in row 3 associated with the values that have 11 in column1 and have a 1 in column2. How do I write the code to do this?
column1 column2 column 3 column 4
11 1 6 5
11 1 8 2
12 1 7 0
21 1 3 8
21 1 2 9

Best Answer

This works:
M = [11 1 6 5
11 1 8 2
12 1 7 0
21 1 3 8
21 1 2 9];
Out = M((M(:,1) == 11) & (M(:,2) == 1),3)
Out =
6
8