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