clc;
clear;
FF=0.4;
sigma1 = 0.1; %
PlotLength =10;
L=100;
length1 = L + 20;
%----- Compute the noise-to-signal ratio--------------------------
na=2;nb=8;nd=1;
n=5;
a=[0.2,-0.2,0.3,0.5,0.17];
par0=[a]';
p0=1000000;r=1;
PP = eye(n)*p0;
par1=ones(n,1)/p0;
%----Generate the input-output data-----------------------------------------
rand('state',1); randn('state',0);
u=(rand(length1,1))*sqrt(1);
v=randn(length1,1)*sigma1;
y = ones(length1,1)/p0;
haty=zeros(length1,1)/p0;
for k=4:(length1)
y(k)=par0(1)*y(k-1)+par0(2)*y(k-2)+par0(3)*y(k-3)+par0(4)*u(k-1)+par0(5)*u(k-2)+v(k);
end
%----DR-M-SG------Generating data---------------------------------------
jj=0;j2=0;
r=0;
for t=4+1:length1
jj=jj+1;
varphi=[y(t-1);y(t-2);y(t-3);u(t-1);u(t-2)];
r=varphi'*varphi;
par1=par1+varphi*(y(t)-varphi'*par1)/r;
delta=norm(par1-par0)/norm(par0);
ls2(jj,:)=[jj, par1', delta];
if ((jj==10)|(jj==20)|(mod(jj,20)==0))|(jj==100)
j2 = j2+1;
ls_20(j2,:)=[jj, par1', delta*100];
end
ls_20(j2+1,:)=[0, par0', 0];
end
fprintf('\n %s \n','$k$ & $a_1$ & $a_2$ & $a_3$ & $b_1$&$b_2$ & $\delta\ (\%)$ \\');
fprintf('%4d & %10.5f & %10.5f & %10.5f & %10.5f & %10.5f & %10.5f &\\\\\n',ls_20');
%fprintf('%10.5f & %10.5f &%10.5f &%10.5f &%10.5f &%10.5f &%10.5f & %10.5f \\\\\n',ls_20);
figure(3); plot(ls2(:,1), ls2(:,n+2),'k');
axis([0, 100, 0, 1])
xlabel('\it k'); ylabel('{\it\tau}');
- 相关评论
- 我要评论
-