root/applications/dual/SIDP/Kopie (2) - finalni implementace/rizeni.m @ 1340

Revision 1113, 1.3 kB (checked in by zimamiro, 14 years ago)
Line 
1function  [ztrata u y b P]=rizeni(H,ny,system,apriori,seed)
2
3sigma=system.sigma;
4N=size(H,1)+2;
5%%chce to mzslet na PYB
6
7y=zeros(1,N);
8b=zeros(1,N);
9P=zeros(1,N);
10u=zeros(1,N-1);
11ztrata=0;
12
13y(1)=apriori(1);
14b(1)=apriori(2);
15P(1)=apriori(3);
16
17    for i=1:size(H,1)
18        eta=abs(y(i))/sigma;
19        beta=abs(b(i))/sqrt(P(i));
20        state=[eta beta];
21       
22        index=find_in_hyperstate5(state, H(i,:,:));
23       
24        %plot(H(i,:,1),H(i,:,2),'g.'); hold on; plot(H(i,index,1), H(i,index,2),'r+'); plot(state(1), state(2),'b.');  hold off
25               
26        znamenko=sign(y(i)*((-1)^(b(i)<0)));
27        u(i)=-ny(i,index)*sigma/sqrt(P(i))*znamenko;
28       
29        y(i+1)=y(i)+system.b*u(i)+sigma*seed(i);
30        K=u(i)*P(i)/(P(i)*u(i)^2+sigma^2);
31        b(i+1)=b(i)+K*(y(i+1)-y(i)-b(i)*u(i));
32        P(i+1)=(1-K*u(i))*P(i);   
33       
34        ztrata=ztrata+(y(i+1)-system.yr(i))^2;
35    end
36    i=i+1;
37    eta=abs(y(i))/sigma;
38    beta=abs(b(i))/sqrt(P(i));
39    u(i)=-eta*beta/(1+beta^2)*sigma/sqrt(P(i))*sign(y(i)*b(i));
40   
41    y(i+1)=y(i)+system.b*u(i)+sigma*randn;
42    K=u(i)*P(i)/(P(i)*u(i)^2+sigma^2);
43    b(i+1)=b(i)+K*(y(i+1)-y(i)-b(i)*u(i));
44    P(i+1)=(1-K*u(i))*P(i);
45    ztrata=ztrata+y(i+1)^2;
46   
47 end
Note: See TracBrowser for help on using the browser.