%1997-2003年数据 A=[83.0, 79.8,78.1,85.1,86.6,88.2,90.3,86.7,93.3,92.5,90.9,96.9; 101.7,85.1,87.8,91.6,93.4,94.5,97.4,99.5,104.2,102.3,101.0,123.5; 92.2,114.0,93.3,101.0,103.5,105.2,109.5,109.2,109.6,111.2,121.7,131.3; 105.0,125.7,106.6,116.0,117.6,118.0,121.7,118.7,120.2,127.8,121.8,121.9; 139.3,129.5,122.5,124.5,135.7,130.8,138.7,133.7,136.8,138.9,129.6,133.7; 137.5,135.3,133.0,133.4,142.8,141.6,142.9,147.3,159.6,162.1,153.5,155.9; 163.2,159.7,158.4,145.2,124,144.1,157.0,162.6,171.8,180.7,173.5,176.5]; T=A(1:6,1:12); x0=mean(T'); x1=zeros(size(x0)); n=length(x0); x1(1)=x0(1); for i=2:n x1(i)=x1(i-1)+x0(i); end z=zeros(size(x0)); af=0.4; for i=2:n z(i)=af*x1(i)+(1-af)*x1(i-1); end Y=zeros(n-1,1); B=zeros(n-1,2); for i=2:n Y(i-1,1)=x0(i); B(i-1,1)=-z(i); B(i-1,2)=1; end Para=inv(B'*B)*B'*Y; a=Para(1); b=Para(2); Pred=(x0(1)-b/a)*exp(-a*n)*(1-exp(a)); Total=12*Pred; r=sum(T)/sum(sum(T)); Px=Total*r; fprintf('输出2003年预测值与实际值. '); for i=1:12 fprintf('%5d ',i); end fprintf(' '); for i=1:12 fprintf('%6.1f',Px(i)); end fprintf(' '); for i=1:12 fprintf('%6.1f',A(7,i)); end fprintf(' '); Error=sum(Px(4:6))-sum(A(7,4:6)); fprintf('2003年4,5,6月SARS导致减少销售额%6.2f亿元 ',Error); subplot(2,1,1); PA=[A(1,:),A(2,:),A(3,:),A(4,:),A(5,:),A(6,:),A(7,:)]; plot(PA);grid on title('原始数据'); subplot(2,1,2); plot(1:12,A(7,:),'b*',1:12,Px,'r'); title('2003年对比数据'); grid on