MATLAB: How to subtract Mean from Matrix along columns

MATLAB

Hi,
In subtraction, there is an example of subtract mean from matrix: A – mean(A) and it works well. But I have a matrix A of 15X1000, and I want to subtract the mean mean(A, 2) along the 1000 columns, how to do that? Thanks Jennifer

Best Answer

With the above help, found that bsxfun works for versions before 2017a:
bsxfun(@minus, A, mean(A, 2))