[1249] | 1 | function [ztrata omega rizeni]=dualni_rizeni(system,apriori,seed)
|
---|
| 2 | kresli=0;
|
---|
| 3 | H_tilde=load('H_tilde.txt');
|
---|
| 4 | C=load('C.txt');
|
---|
| 5 |
|
---|
| 6 | horizont=system.horizont_rizeni;
|
---|
| 7 | if nargin<3
|
---|
| 8 | seed=randn(6,horizont);
|
---|
| 9 | end
|
---|
| 10 | ztrata=0;
|
---|
| 11 | H=apriori.H;
|
---|
| 12 | x_hat=H(:,1);
|
---|
| 13 |
|
---|
| 14 | system.S=zeros(1,3);
|
---|
| 15 | for i=1:horizont
|
---|
| 16 | [u system]=control(system,x_hat,interpol(H,H_tilde,C,system.H_tilde_on));
|
---|
| 17 | [u system]=control(system,x_hat,-20);
|
---|
| 18 | rizeni(:,i)=u;
|
---|
| 19 | [system.x system.pozorovani]=get_next(system,system.x,u,seed(:,i));
|
---|
| 20 | H=kalman_filter(H,u,system);
|
---|
| 21 | x_hat=H(:,1);
|
---|
| 22 | omega(1,i)=system.x(3);
|
---|
| 23 | omega(2,i)=x_hat(3);
|
---|
| 24 | theta(1,i)=system.x(4);
|
---|
| 25 | theta(2,i)=x_hat(4);
|
---|
| 26 | ztrata= ztrata+u'*system.gamma*u+(system.x-system.x_opt)'*system.ksi*(system.x-system.x_opt);
|
---|
| 27 | neurcitost(i)=H(3,4);
|
---|
| 28 | zas(:,i)=u;
|
---|
| 29 | end
|
---|
| 30 | if (kresli)
|
---|
| 31 | figure
|
---|
| 32 | plot(zas(1,:)); hold on
|
---|
| 33 | plot(zas(2,:)); hold off
|
---|
| 34 | figure
|
---|
| 35 | plot(omega(1,:),'-'); hold on
|
---|
| 36 | plot(omega(2,:),'.-.'); hold off
|
---|
| 37 | legend('SKUTECNE','ODHAD');
|
---|
| 38 | figure
|
---|
| 39 | plot(theta(1,:),'-'); hold on
|
---|
| 40 | plot(theta(2,:),'.-.'); hold off
|
---|
| 41 | legend('SKUTECNE','ODHAD');
|
---|
| 42 | figure
|
---|
| 43 | plot(neurcitost)
|
---|
| 44 | ztrata
|
---|
| 45 | end
|
---|
| 46 | end |
---|