clc
close all
clear all

a1=0.93;
b1=1.5;
b2=-3;
th=[a1;b1;b2];

T=1e3;
Tin=3;

u=10*(-1+2*rand(T,1));
y=zeros(Tin-1,1);
L=[];
Y=[];

for t=Tin:T
   
   d(t)=3*randn;
   
   phi(:,t)=[-y(t-1);u(t-1);u(t-2)];
   y(t)=phi(:,t)'*th+d(t);
   
   L=[L;phi(:,t)'];
   Y=[Y;y(t)];
   
   th_h(:,t)=L\Y;
   
end

figure
plot(y)

figure,hold on
plot(th_h(1,:))
plot(th_h(2,:),'r')
plot(th_h(3,:),'g')

