求一个三次指数平滑的matlab程序。。。。。。。。。急急急急急。。。

求高手指点指点啊。。。我自己编的程序总是提示
“??? end s3=y(1);
|
Error: Unexpected MATLAB expression“

close all
clear,clc

% 统计数据 实际值
arr = [143 152 161 139 137 174 142 141 162 180 164 171 206 193 207 218 229 225 204 227 223 242 239 266]';

[m,nn]=size(arr);
alpha = 0.15; % 平滑常数的范围为[0,1]

% 1次指数平滑
s1 = zeros(m,1);
s1(1,1) = arr(1,1);
for i=2:m
s1(i) = alpha*arr(i,1)+(1-alpha)*s1(i-1);
end
sx1 = s1

% 2次指数平滑
s2 = zeros(m,1);
s2(1,1) = arr(1,1);
for i=2:m
s2(i) = alpha*s1(i,1)+(1-alpha)*s2(i-1);
end
sx2 = s2

% 3次指数平滑
s3 = zeros(m,1);
s3(1,1) = arr(1,1);
for i=2:m
s3(i) = alpha*s2(i,1)+(1-alpha)*s3(i-1);
end
sx3 = s3

% 计算二次曲线中的参数
a = zeros(m,1);
b = zeros(m,1);
c = zeros(m,1);
beta=alpha/(2*(1-alpha)*(1-alpha));
a = 3*sx1-3*sx2+sx3;
b = beta*((6-5*alpha)*sx1-2*(5-4*alpha)*sx2+(4-3*alpha)*sx3);
c = beta*alpha*(sx1-2*sx2+sx3);

% 二次曲线模型 a+b*t+c*t*t
t = 1; %
sf = zeros(m,1);
% sf(1,1) = arr(1,1);
sf = a+b*t+c*t*t % 预测

参考资料:http://hi.baidu.com/zzz700/blog/item/c2fe49209b7cd77d34a80f14.html

温馨提示:答案为网友推荐,仅供参考
第1个回答  2017-11-15
s1(i) = alpha*arr(i,1)+(1-alpha)*s1(i-1); 错
s2(i) = alpha*s1(i,1)+(1-alpha)*s2(i-1);错
s3(i) = alpha*s2(i,1)+(1-alpha)*s3(i-1);错
改为
s1(i) = alpha*arr(i-1,1)+(1-alpha)*s1(i-1); 以此类推
第2个回答  2011-11-27
嗯,换行
第3个回答  2011-11-27
驻俄格我也不知道本回答被网友采纳
相似回答