function stdOut = standardize(in); %standardize Standardize each column of a matrix. % % Standardize each column of an input matrix by subtracting % the column mean and dividing by the standard deviation of % the column. % % USE: % out = standardize(in) % % Tomo Eguchi % 24 January 2002 %in = [normrnd(3,1,10,1), normrnd(5,4,10,1), normrnd(2,6,10,1)]; meanVec = mean(in); stdVec = std(in); [nr, nc] = size(in); stdOut = (in - repmat(meanVec, nr, 1))./(repmat(stdVec, nr, 1));