clear;
%function y=zxg(N)
N=50;
X=[15.08,20.14,24.36,27.86,30.14,32.86,34.85,37.24,39.39,41.45,43.48,45.28,47.26,49.40,51.07,52.97,54.48,56.00,57.24,59.06,60.75,62.49,64.45,66.53,68.73,70.82,72.92,75.39,77.01,79.15,81.48,83.31,85.10,86.59,88.38,90.29,94.61,95.15,97.30,99.66,102.63,105.43,107.77,109.69,111.53,113.28,115.18,117.42,120.13,122.69];
%Y=X-70.9094
%X=[5.12,4.22,3.50,2.55,2.45,1.99,2.39,2.15,2.06,1.93,1.90,1.98,2.14,1.69,1.88,1.51,1.52,1.54,1.52,1.69,1.74,1.96,2.08,2.20,2.09,2.10,2.47,1.62,2.14,2.33,1.83,1.79,1.49,1.79,1.91,4.32,0.54,2.15,2.36,2.97,2.80,2.34,1.92,1.84,1.75,1.90,2.24,2.71,2.56];
%X=[101 82 66 35 31 7 20 92 154 125 85 68 38 23 10 24 83 132 131 118 90 67 60 47 41 21 16 6 4 7 14 34 45 43 48 42 28 10 8 2 0 1 5 12 14 35 46 41 30 24 16 7 4 2 8 17 36 50 62 67 71 48 28 8 13 57 122 138 103 86 63 37 24 11 15 40 62 98 124 96 66 64 54 39 21 7 4 23 55 94 96 77 59 44 47 30 16 7 37 74];
%X=[47 64 23 71 38 64 55 41 59 48 71 35 57 40 58 44 80 55 37 74 51 57 50 60 45 57 50 45 25 59 50 71 56 74 50 58 45 54 36 54 48 55 45 57 50 62 44 64 43 52 38 59 55 41 53 49 34 35 54 45 68 38 50 60 39 59 40 57 54 23];
x=0;
for i=1:N
x=x+X(i);
end
x=x/N;
Y=X-x;
e=0;
b=0;
r=ones(1,N);
p=zeros(1,N);
for c=0:N-1
sum=0;
e=e+1;
for d=e:N
sum=sum+Y(d)*Y(d-b);
end
b=b+1;
r(c+1)=sum;
p(c+1)=r(c+1)/r(1);
end
subplot(211);plot(p);
n=N-2;
B=0;
C=0;
A=zeros(n);
%for e=1;N-1
% p(e)=p(e+1);
%end
A(1,1)=p(2);
for k=1:n;
for i=1:k
for j=1:k
B=B+p(k+2-j)*A(k,j);
C=C+p(j+1)*A(k,j);
end
C=1/(1-C);
A(k+1,k+1)=(p(k+2)-B)*C;
A(k+1,k+1-i)=A(k,k+1-i)-A(k+1,k+1)*A(k,i);
B=0;
C=0;
end
end
L=ones(1,N);
for i=1:n
L(i)=A(i,i);
end
subplot(212);plot(L);
其中X是你的序列,N是序列长度,这样可以画出一个时间序列的自相关函数和偏自相关函数图! |