root/applications/dual/SIDP/bakalarka/SIDPS/matlab/motor2/dualni_rizeni.m @ 1351

Revision 1351, 1.1 kB (checked in by zimamiro, 13 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    rizeni(:,i)=u;
18    [system.x system.pozorovani]=get_next(system,system.x,u,seed(:,i));
19    H=kalman_filter(H,u,system);
20    x_hat=H(:,1);
21    omega(1,i)=system.x(3);
22    omega(2,i)=x_hat(3);
23    theta(1,i)=system.x(4);
24    theta(2,i)=x_hat(4);
25    ztrata= ztrata+u'*system.gamma*u+(system.x-system.x_opt)'*system.ksi*(system.x-system.x_opt);
26    neurcitost(i)=H(3,4);
27    zas(:,i)=u;
28end
29if (kresli)
30figure
31plot(zas(1,:)); hold on
32plot(zas(2,:)); hold off
33figure
34plot(omega(1,:),'-'); hold on
35plot(omega(2,:),'.-.'); hold off
36legend('SKUTECNE','ODHAD');
37figure
38plot(theta(1,:),'-'); hold on
39plot(theta(2,:),'.-.'); hold off
40legend('SKUTECNE','ODHAD');
41figure
42plot(neurcitost)
43ztrata
44end
45end
Note: See TracBrowser for help on using the browser.