⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 autocor.m

📁 偏最小二乘算法在MATLAB中的实现
💻 M
字号:
function acor = autocor(x,n,period)
%AUTOCOR Autocorrelation of time series
% Performs the autocorrelation function of a time series.
% The inuputs are the time series vector (x),
% the number of sample periods to consider (n),
% and the optional variable of the sample time
% (period) which is used to scale the output plot.
% The output is the autocorrelation function (acor).
% I/O format it: acor = autocor(x,n,period);

%  Copyright
%  Barry M. Wise
%  1992
%  Modified November 1993
[mp,np] = size(x);
if np > mp
  x = x';
  mp = np;
end
acor = zeros(2*n+1,1);
ax = auto(x);
for i = 1:n
  ax1 = ax(1:mp-n-1+i,1);
  ax2 = ax(n+2-i:mp,1);
  acor(i,1) = ax1'*ax2/(mp-n+i-2);
end
acor(n+1,1) = ax'*ax/(mp-1);
for i = 1:n
  acor(n+i+1) = acor(n+1-i);
end 
if nargin == 3
  scl = period*(-n:1:n);
else
  scl = -n:1:n;
end
plot(scl,acor)
title('Autocorrelation Function')
xlabel('Signal Time Shift (Tau)')
ylabel('Correlation [ACF(Tau)]') 
hold on
plot(scl,zeros(size(scl)),'--g',[0 0],[-1 1],'--g')
axis([scl(1,1) -scl(1,1) -1 1])
hold off

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -