MATLAB: How to find the mean of one column based on the value in another column

column conditionmean

I want to find the mean of the values in the second column only for the rows which have the value 3 in column 10 I have tried mean = mean(data(data(:,10)==3,8))

Best Answer

You command is correct (beside using 8th column instead of 2nd) BUT:
Don't name your (output) variable MEAN, you will have conflict later when using function MEAN.
Related Question