% % Written by: % -- % John L. Weatherwax 2009-04-21 % % email: wax@alum.mit.edu % % Please send comments and especially bug reports to the % above email address. % %----- close all; drawnow; clear functions; rehash; clc; theta_1 = 0.81; theta_2 = -0.38; a = zeros(1,10); % now % a(1) is a_{91} ... set to zero % a(2) is a_{92} ... set to zero % ... % a(10) is a_{100} % z = [ 15.1, 15.8, 15.9, 15.2, 15.9, 16.5, 17.1, 16.9, 17.3, 18.2 ]; % now % z(1) is z_{91} % z(2) is z_{92} % ... % z(10) is z_{100} % znof1 = zeros(1,10); % now % znof1(1) is z_{91}(1) ... not needed or used % znof1(2) is z_{92}(1) ... first element filled % .... % znof1(9) is z_{99}(1) % znof1(10) is z_{100}(1) ... last element filled % for ii=2:9 znof1(ii) = 2*z(ii) - z(ii-1) - theta_1 * a(ii) - theta_2 * a(ii-1); a(ii+1) = z(ii+1) - znof1(ii); end ii=10; % do the last point by hand (n=100) ... this is also z_{100}(1) or the first prediction from n=100 znof1(ii) = 2*z(ii) - z(ii-1) - theta_1 * a(ii) - theta_2 * a(ii-1); z_100_l = zeros(1,10); % <- storage ... z_100_l(1) = znof1(ii); % <- computed above z_{100}(1) % do the rest of the predictions: first z_{100}(2) z_100_l(2) = 2*z_100_l(1) - z(end) - theta_2 * a(end); % now z_{100}(l) for l >= 3 for ll=3:10, z_100_l(ll) = 2*z_100_l(ll-1) - z_100_l(ll-2); end