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