root/applications/dual/SIDP/SIDPS/motor_sidps/dualni_rizeni.m @ 1249

Revision 1249, 1.1 kB (checked in by zimamiro, 14 years ago)
Line 
1function [ztrata omega rizeni]=dualni_rizeni(system,apriori,seed)
2kresli=0;
3H_tilde=load('H_tilde.txt');
4C=load('C.txt');   
5
6horizont=system.horizont_rizeni;
7if nargin<3
8        seed=randn(6,horizont);
9end
10ztrata=0;
11H=apriori.H;
12x_hat=H(:,1);
13
14system.S=zeros(1,3);
15for 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;
29end
30if (kresli)
31figure
32plot(zas(1,:)); hold on
33plot(zas(2,:)); hold off
34figure
35plot(omega(1,:),'-'); hold on
36plot(omega(2,:),'.-.'); hold off
37legend('SKUTECNE','ODHAD');
38figure
39plot(theta(1,:),'-'); hold on
40plot(theta(2,:),'.-.'); hold off
41legend('SKUTECNE','ODHAD');
42figure
43plot(neurcitost)
44ztrata
45end
46end
Note: See TracBrowser for help on using the browser.