root/applications/bdmtoolbox/tutorial/userguide/dist_ctrl_example.m @ 744

Revision 744, 1.1 kB (checked in by smidl, 15 years ago)

Working unitsteps and controlloop + corresponding fixes

Line 
1% name random variables
2y = RV({'y'},1);
3u1 = RV({'u1'},1);
4u2 = RV({'u2'},1);
5
6% create f(y_t| y_{t-3}, u_{t-1})
7fy.class = 'mlnorm<ldmat>';
8fy.rv    = y;
9fy.rvc   = RVtimes([y,u1,u2], [-3, 0, 0]);
10fy.A     = [0.5, -0.9, 0.9];
11fy.const = 0;
12fy.R     = 1e-2;
13
14DS.class = 'PdfDS';
15DS.pdf = fy;
16
17% create ARX estimator
18A1.class = 'ARX';
19A1.rv = y;
20A1.rgr = RVtimes([y,u1],[-3,0]) ; % correct structure is {y,y}
21A1.options ='logbounds,logll';
22A1.frg = 0.95;
23
24A2=A1;
25A2.rgr = RVtimes([y,u2],[-3,0]) ; % correct structure is {y,y}
26
27
28C1.class = 'LQG_ARX';
29C1.ARX = A1;
30C1.Qu = 0.1*eye(1);
31C1.Qy = 1*eye(1);
32C1.yreq = 1;
33C1.horizon = 100;
34
35C2=C1;
36C2.ARX = A2;
37
38M= controlloop(DS,{C1,C2});
39
40
41%%%%%%%%%%%%%%%%%%%%%%%%%%%%
42%       PLOTS
43
44figure(1);
45hold off
46subplot(1,2,1);
47plot(M.DS_y);
48subplot(1,2,2);
49plot(M.DS_u1); hold on;
50plot(M.DS_u2);
51
52figure(2);
53hold off
54plot(M.Ctrl0_apost_mean_theta);
55hold on
56plot(M.Ctrl0_apost_ub_theta,':');
57plot(M.Ctrl0_apost_lb_theta,':');
58set(gca,'YLim',[-4,2]);
59
60figure(3);
61hold off
62plot(M.Ctrl1_apost_mean_theta);
63hold on
64plot(M.Ctrl1_apost_ub_theta,':');
65plot(M.Ctrl1_apost_lb_theta,':');
66set(gca,'YLim',[-2,3]);
Note: See TracBrowser for help on using the browser.