📄 center.m
字号:
function [xc, xm] = center(x)%CENTER Centers data by subtraction of the mean.%% [XC, XM] = CENTER(X) centers the data in X by subtraction of the% mean XM. If X contains NaNs, indicating missing values, the mean% of X is computed from the available data.%% See also NANMEAN, MEAN. error(nargchk(1,1,nargin)) % check number of input arguments if ndims(x) > 2, error('X must be vector or 2-D array.'); end % if x is a vector, make sure it is a row vector if length(x)==prod(size(x)) x = x(:); end [m,n] = size(x); % get mean of x if any(any(isnan(x))) % there are missing values in x xm = nanmean(x); else % no missing values xm = mean(x); end % remove mean xc = x - repmat(xm, m, 1);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -