%% Deviation of Matrix Elements from Column Mean
% Subtract the column mean from the corresponding column elements of a matrix A. Then normalize by the standard deviation.

A = [1 2 10; 3 4 20; 9 6 15];
C = bsxfun(@minus, A, mean(A));
D = bsxfun(@rdivide, C, std(A))

%
% In MATLAB® R2016b and later, you can directly use operators instead of bsxfun, since the operators independently support implicit expansion of arrays with compatible sizes.

(A - mean(A))./std(A)

% Copyright 2012 The MathWorks, Inc.