comparaison entre mcr mcg 1

2
%Comparaison entre MCR & MCG clear clc N=1000; %for i=1:N u(i)=1; end %initialization de victor u1=ones(1,N); %%Calcule teta_MCR p=1000*eye(2); tetar=zeros(2,2); y=[0 0]; for i=3:N h(:,1)=[y(i-1) u1(i)]'; K=p*h; y(i)=[0.2 2]*h(:,1)+0.1*(-0.5+rand); tetar(:,i)=tetar(:,i-1)+K*(y(i)-tetar(:,i-1)'*h)/(1+h'*p*h); p=p-(p*h*h'*p)/(1+h'*p*h); end teta_MCR=tetar(:,i) %%Calcule teta_MCG u2=1000*eye(2); teta_MCG=zeros(2,1); f1=0; y2=0; pe=1000; for i=3:N e=0;

Upload: mahdilabed

Post on 25-Sep-2015

221 views

Category:

Documents


8 download

DESCRIPTION

mcg

TRANSCRIPT

  • %Comparaison entre MCR & MCGclearclcN=1000;%for i=1:N u(i)=1; end%initialization de victoru1=ones(1,N);

    %%Calcule teta_MCRp=1000*eye(2);tetar=zeros(2,2);y=[0 0];for i=3:N

    h(:,1)=[y(i-1) u1(i)]';K=p*h;y(i)=[0.2 2]*h(:,1)+0.1*(-0.5+rand);tetar(:,i)=tetar(:,i-1)+K*(y(i)-tetar(:,i-1)'*h)/(1+h'*p*h);p=p-(p*h*h'*p)/(1+h'*p*h);

    endteta_MCR=tetar(:,i)

    %%Calcule teta_MCGu2=1000*eye(2);teta_MCG=zeros(2,1);f1=0;y2=0;pe=1000;for i=3:N

    e=0;

  • uF(i)=u1(i)+f1*u1(i-1);yF(i)=y(i)+f1*y(i-1);hg(:,1)=[yF(i-1) uF(i)]';u2=u2-(u2*hg*hg'*u2)/(1+hg'*u2*hg);Kg=u2*hg;teta_MCG=teta_MCG+Kg*(yF(i) -hg'*teta_MCG);e=y2-h'*teta_MCG;he=e;pe=pe-pe*he*he'*pe/(1+he'*pe*he);Ke=pe*he;f1=f1+Ke*(e-he'*f1);

    endteta_MCG

    sum((teta_MCR-[0.2;2]).^2)sum((teta_MCG-[0.2;2]).^2)