function rx = mdrescal(x,flag,mx,stdx) %MDRESCAL Rescales matrix with missing data as specified. % Rescales a matrix (x) with missing data indicated by % (flag) using means (mx) and standard deviations (stds) % specified. % % I/O format is: rx = mdrescal(x,flag,mx,stdx); % % If only three input arguments are supplied then the function % will not do variance rescaling, but only vector addition. % % I/O format is: rx = mdrescal(x,flag,mx); % % See also: MDAUTO, MDMNCN, MDSCALE % Copyright Eigenvector Research 1997 % By Barry M. Wise [m,n] = size(x); rx = ones(m,n)*flag; if nargin == 4 for i = 1:n z = find(x(:,i)~=flag); rx(z,i) = (x(z,i)*stdx(i))+mx(i); end else for i = 1:n z = find(x(:,i)~=flag); rx(z,i) = (x(z,i)+mx(i)); end end