I have an array of which I need the mean of each column (X). Additionally, I have a logical array of which rows meet a condition and should be included in the mean (Y).
Naturally, the mean function in MATLAB calculates each column mean, but when I insert the logical vector for the row selection, the mean is calculated for the whole array. How do I fix this for computing the mean of each column in X for the valid indices of Y?
means_active = mean(X(Y), :);
I get the error 'Reference to a cleared variable mean.', though I don't want to use any variable 'mean' but the built-in function 'mean'.