comparaison entre mcr mcg 2

2
%%%%%%%%%%%%etude comparative entre MCR et MCG%%%%%%%%%%%%%%%%%%%%%%%%%%% clear clc y2=0;p=8*eye(2);teta_mcr=[0;0];K=[] teta_mcg=[0;0];u(1:300)=ones(300,1); exprnd(1,2,1) for k=2:300 b2=0.1*(-0.5+rand) b1=b2; y1=y2; y2=0.2*y1+2*u(k)+b1+10*b2; h=[y1 u(k)]'; p=p-(p*h*h'*p)/(1+h'*p*h); K=p*h; teta_mcr=teta_mcr+K*(y2-h'*teta_mcr) end teta_mcg=[0;0];pe=1000;Ke=[];f1=0;e2=0;u(1:300)=ones(300,1); y2F=0;pg=1000*eye(2); for k=2:300 uF=u(k)+f1*u(k-1); y1F=y2F; y2F=y2+f1*y2; hg=[y1F uF]'; pg=pg-(pg*hg*hg'*pg)/(1+hg'*pg*hg); Kg=pg*hg; teta_mcg=teta_mcg+Kg*(y2F -hg'*teta_mcg) e1=e2; e2=y2-h'*teta_mcg;

Upload: mahdilabed

Post on 09-Nov-2015

215 views

Category:

Documents


0 download

DESCRIPTION

mcr

TRANSCRIPT

  • %%%%%%%%%%%%etude comparative entre MCR et MCG%%%%%%%%%%%%%%%%%%%%%%%%%%%clearclcy2=0;p=8*eye(2);teta_mcr=[0;0];K=[]teta_mcg=[0;0];u(1:300)=ones(300,1);exprnd(1,2,1)for k=2:300

    b2=0.1*(-0.5+rand)b1=b2;

    y1=y2;

    y2=0.2*y1+2*u(k)+b1+10*b2;h=[y1 u(k)]';

    p=p-(p*h*h'*p)/(1+h'*p*h);K=p*h;teta_mcr=teta_mcr+K*(y2-h'*teta_mcr)endteta_mcg=[0;0];pe=1000;Ke=[];f1=0;e2=0;u(1:300)=ones(300,1);y2F=0;pg=1000*eye(2);for k=2:300uF=u(k)+f1*u(k-1);y1F=y2F;

    y2F=y2+f1*y2;hg=[y1F uF]';pg=pg-(pg*hg*hg'*pg)/(1+hg'*pg*hg);Kg=pg*hg;teta_mcg=teta_mcg+Kg*(y2F -hg'*teta_mcg)e1=e2;e2=y2-h'*teta_mcg;

  • he=e1;pe=pe-pe*he*he'*pe/(1+he'*pe*he);Ke=pe*he;f1=f1+Ke*(e2-he'*f1);end

    sum((teta_mcr-[0.2;2]).^2)sum((teta_mcg-[0.2;2]).^2)