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

Revision 934, 1.3 kB (checked in by smidl, 14 years ago)

use clear all + new mex

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