Revision 1351, 0.9 kB
(checked in by zimamiro, 13 years ago)
|
|
Line | |
---|
1 | function [ztrata omega]=jednoduche_rizeni(system,apriori)
|
---|
2 | kresli=0;
|
---|
3 | horizont=system.horizont_rizeni;
|
---|
4 | ztrata=0;
|
---|
5 | H=apriori.H;
|
---|
6 | x_hat=H(:,1);
|
---|
7 |
|
---|
8 | system.S=zeros(1,3);
|
---|
9 | for i=1:horizont
|
---|
10 | [u system]=simple_control(system,x_hat);
|
---|
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 | if(kresli)
|
---|
23 | figure
|
---|
24 | plot(zas(1,:)); hold on
|
---|
25 | plot(zas(2,:)); hold off
|
---|
26 | figure
|
---|
27 | plot(omega(1,:),'-'); hold on
|
---|
28 | plot(omega(2,:),'.-.'); hold off
|
---|
29 | legend('SKUTECNE','ODHAD');
|
---|
30 | figure
|
---|
31 | plot(theta(1,:),'-'); hold on
|
---|
32 | plot(theta(2,:),'.-.'); hold off
|
---|
33 | legend('SKUTECNE','ODHAD');
|
---|
34 | figure
|
---|
35 | plot(neurcitost)
|
---|
36 | ztrata
|
---|
37 | end
|
---|
38 |
|
---|
39 | end |
---|