MATLAB: Mean of Matrix Rows

matrixmeanrow

For any matrix A, how would I subtract the row means from each row, so that each row has a mean of zero?

Best Answer

The row means would be calculated as the mean of dimension 2.
Try this:
A = rand(5);
Anew = A - mean(A,2);
Check = mean(Anew,2) % Confirm: Mean = 0