Revision 1351, 1.0 kB
(checked in by zimamiro, 13 years ago)
|
|
Rev | Line | |
---|
[1351] | 1 | function [ztrata omega rizeni]=jednoduche_rizeni(system,apriori,seed)
|
---|
| 2 | kresli=0;
|
---|
| 3 | horizont=system.horizont_rizeni;
|
---|
| 4 | if nargin<3
|
---|
| 5 | seed=randn(6,horizont);
|
---|
| 6 | end
|
---|
| 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,0);
|
---|
| 14 | rizeni(:,i)=u;
|
---|
| 15 | [system.x system.pozorovani]=get_next(system,system.x,u,seed(:,i));
|
---|
| 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 |
---|