root/applications/dual/SIDP/bakalarka/SIDPS/matlab/motor_sidps/dualni_rizeni.asv @ 1351

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