码迷,mamicode.com
首页 > 其他好文 > 详细

灰色系统模型

时间:2020-02-07 11:12:57      阅读:73      评论:0      收藏:0      [点我收藏+]

标签:print   ota   对比   灰色   pre   a*   grid   printf   输出   

%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年预测值与实际值.\n‘);
for i=1:12
    fprintf(‘%5d ‘,i);
end
fprintf(‘\n‘);
for i=1:12
    fprintf(‘%6.1f‘,Px(i));
end
fprintf(‘\n‘);
for i=1:12
    fprintf(‘%6.1f‘,A(7,i));
end
fprintf(‘\n‘);
Error=sum(Px(4:6))-sum(A(7,4:6));
fprintf(‘2003年4,5,6月SARS导致减少销售额%6.2f亿元\n‘,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

  

灰色系统模型

标签:print   ota   对比   灰色   pre   a*   grid   printf   输出   

原文地址:https://www.cnblogs.com/kmxojer/p/12272082.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!