autocorr.m
来自「list of matlab m-files on matlab 7.0. le」· M 代码 · 共 39 行
M
39 行
function r=autocorr(y,N,wtype,opt);% Usage: r=autocorr(y,N,wtype,opt);% Sample autocorrelation lags calculation % r=R(0:N-1)% y: a vector% N: # of autocorrelation lags% wtype: types of window used% = 0, default: rectangular window% = 1, triangular window% opt = 0 (default) make y to zero mean before finding auto-correlation lags% = 1 do not make y zero mean (or y is already zero mean)% created: 10/27/2001if nargin<4, opt=0; end % converting y to zero meanif opt==0, y=y-mean(y); endif nargin<3, % if wtype is not specified wtype=0; % use default valueendy=diag(diag(y)); % make sure it is a column vectorlen=length(y); if N>1, A=toeplitz(y,[y(1) zeros(1,N-1)]);elseif N==1, A=y;endif wtype==0, % rectangular window (default) r=y'*A./[len:-1:len-N+1];elseif wtype==1, % triangular window r=y'*A/len;end
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?