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

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

New mexes + corrected tutorial

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 = RV({'theta','r'},[3,1]);
21A1.yrv = y;
22A1.rgr = RVtimes([y,u1],[-3,0]) ; % correct structure is {y,y}
23A1.log_level ='logbounds,logevidence,logmean';
24A1.frg = 0.95;
25
26A2=A1;
27A2.rgr = RVtimes([y,u2],[-3,0]) ; % correct structure is {y,y}
28
29
30C1.class = 'LQG_ARX';
31C1.ARX = A1;
32C1.Qu = 0.1*eye(1);
33C1.Qy = 1*eye(1);
34C1.yreq = 1;
35C1.horizon = 100;
36
37C2=C1;
38C2.ARX = A2;
39
40exper.Ndat=100;
41exper.burnin=3;
42exper.burn_pdf.class='enorm<chmat>';
43exper.burn_pdf.mu=[0,0];
44exper.burn_pdf.R=0.1*eye(2);
45
46
47M= controlloop(DS,{C1,C2},exper);
48
49
50%%%%%%%%%%%%%%%%%%%%%%%%%%%%
51%       PLOTS
52
53figure(1);
54hold off
55subplot(1,2,1);
56plot(M.DS_dt_y);
57subplot(1,2,2);
58plot(M.DS_dt_u1); hold on;
59plot(M.DS_dt_u2);
60
61figure(2);
62hold off
63plot(M.Ctrl0_apost_mean_theta);
64hold on
65plot(M.Ctrl0_apost_ub_theta,':');
66plot(M.Ctrl0_apost_lb_theta,':');
67set(gca,'YLim',[-4,2]);
68
69figure(3);
70hold off
71plot(M.Ctrl1_apost_mean_theta);
72hold on
73plot(M.Ctrl1_apost_ub_theta,':');
74plot(M.Ctrl1_apost_lb_theta,':');
75set(gca,'YLim',[-2,3]);
Note: See TracBrowser for help on using the browser.