matlab学习笔记 灰度预测

matlab学习笔记 灰度预测_第1张图片

A=[1,2,3,4,5,6,7,8,9,10];

B=cumsum(A);
n=length(A);
for i=1:(n-1)
C(i)=(B(i)+B(i+1))/2;
end
D=A;
D(1)=[];
D=D';
E=[-C;ones(1,n-1)];
c=inv(E*E')*E*D;
c=c';
a=c(1);
b=c(2);
F=[];
F(1)=A(1);
for i=2:(n+10)
F(i)=(A(1)-b/a)/exp(a*(i-1))+b/a;
end
G=[];
G(1)=A(1);
for i=2:(n+10)
G(i)=F(i)-F(i-1);
end
t1=1999:2008;
t2=1999:2018;
G
plot(t1,A,'o',t2,G)

你可能感兴趣的:(matlab学习笔记 灰度预测)