MATLAB: Matrix Averaging

averaging

Hi, I'm trying to do something very simple, but can't seem to get the if condition correct.
I want to find the average of (:,2:5) if the values in the first column of the matrix are below a certain average.
Thanks in advance,
Ready to be humbled—

Best Answer

If A is your matrix and tol stands for "a certain average,"
if mean(A(:,1))<tol
M = mean(A(:,2:5));
end