matlab 时间序列模型求解yt=[101.5 102.7 102.4 102.8 103.1 102.9 103.3 103.5 103.6 104.4 105.1 104.6 104.9 104.9 105.4 105.3 105.5 106.4 106.5]n=length(yt); alpha=0.2; st1(1)=yt(1); st2(1)=yt(1); for i=2:n st1(i)=alpha*yt(i)+(1-alpha)*st1(i-1)s
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/18 19:56:46
matlab 时间序列模型求解yt=[101.5 102.7 102.4 102.8 103.1 102.9 103.3 103.5 103.6 104.4 105.1 104.6 104.9 104.9 105.4 105.3 105.5 106.4 106.5]n=length(yt); alpha=0.2; st1(1)=yt(1); st2(1)=yt(1); for i=2:n st1(i)=alpha*yt(i)+(1-alpha)*st1(i-1)s
matlab 时间序列模型求解
yt=[101.5 102.7 102.4 102.8 103.1 102.9 103.3 103.5 103.6 104.4 105.1 104.6 104.9 104.9 105.4 105.3 105.5 106.4 106.5]
n=length(yt);
alpha=0.2; st1(1)=yt(1); st2(1)=yt(1);
for i=2:n
st1(i)=alpha*yt(i)+(1-alpha)*st1(i-1)
st2(i)=alpha*st1(i)+(1-alpha)*st2(i-1)
end
%xlswrite('cpi2.xls',[st1',st2'])
a=2*st1-st2
b=alpha/(1-alpha)*(st1-st2)
yhat=a+b
%xlswrite('cpi2.xls',yhat','Sheet1','C2')
str=char(['C',int2str(n+2)]);
c=a(n)+b(n)
z=yhat-yt
plot(1:n,yt,'*',1:n,yhat(1:n),'O')
legend('实际值','预测值',2)
将这段代码中的yt=[101.5 102.7 102.4 102.8 103.1 102.9 103.3
103.5 103.6 104.4 105.1 104.6 104.9 104.9 105.4
105.3 105.5 106.4 106.5]改为yt=[102.7 104.0 103.2 104.9 105.0 104.7 106.1 106.5 105.9 104.1 103.7 102.7 104.1】即把19个数据改为13个数据,需要改其他地方的什么代码才能成功运行?
matlab 时间序列模型求解yt=[101.5 102.7 102.4 102.8 103.1 102.9 103.3 103.5 103.6 104.4 105.1 104.6 104.9 104.9 105.4 105.3 105.5 106.4 106.5]n=length(yt); alpha=0.2; st1(1)=yt(1); st2(1)=yt(1); for i=2:n st1(i)=alpha*yt(i)+(1-alpha)*st1(i-1)s
把yt数据换了,最前面再加上一句clear st1 st2就可以了(或者更简单一点,直接clear也行).