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

Revision 871, 1.2 kB (checked in by mido, 14 years ago)

adaptation of /applications to new version of LOG_LEVEL
also, a cosmetic change made in enumerations: logub -> logubound, loglb -> loglbound

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.log_level ='logbounds,logevidence';
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
38exper.Ndat=100;
39exper.burnin=3;
40exper.burn_pdf.class='enorm<chmat>';
41exper.burn_pdf.mu=[0,0];
42exper.burn_pdf.R=0.1*eye(2);
43
44
45M= controlloop(DS,{C1,C2},exper);
46
47
48%%%%%%%%%%%%%%%%%%%%%%%%%%%%
49%       PLOTS
50
51figure(1);
52hold off
53subplot(1,2,1);
54plot(M.DS_y);
55subplot(1,2,2);
56plot(M.DS_u1); hold on;
57plot(M.DS_u2);
58
59figure(2);
60hold off
61plot(M.Ctrl0_apost_mean_theta);
62hold on
63plot(M.Ctrl0_apost_ub_theta,':');
64plot(M.Ctrl0_apost_lb_theta,':');
65set(gca,'YLim',[-4,2]);
66
67figure(3);
68hold off
69plot(M.Ctrl1_apost_mean_theta);
70hold on
71plot(M.Ctrl1_apost_ub_theta,':');
72plot(M.Ctrl1_apost_lb_theta,':');
73set(gca,'YLim',[-2,3]);
Note: See TracBrowser for help on using the browser.