root/applications/bdmtoolbox/tutorial/userguide/arx_windsurfer_example.m @ 1134

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

New mexes + corrected tutorial

Line 
1clear all
2% name random variables
3y = RV({'y'},1);
4u = RV({'u'},1);
5
6% create f(y_t| y_{t-3}, u_{t-1})
7fy.class = 'mlnorm<ldmat>';
8fy.rv    = y;
9fy.rvc   = RVtimes([y,u], [-3, -1]);
10fy.A     = [0.5, -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.yrv = y;
20A1.rgr = RVtimes([y,u],[-3,-1]) ; % correct structure is {y,y}
21A1.log_level ='logbounds,logevidence';
22
23C1.class = 'LQG_ARX';
24C1.ARX = A1;
25C1.Qu = 100*eye(1);
26C1.Qy = 100*eye(1);
27C1.yreq = 1;
28C1.horizon = 10;
29
30C2 = C1;
31C2.windsurfer = 1;
32
33N = 10;
34losses_plain=zeros(1,N);
35losses_wind =zeros(1,N);
36
37for i=1:10
38    M= controlloop(DS,{C1});
39    losses_plain(i) = (M.DS_dt_y - C1.yreq)'*(M.DS_dt_y - C1.yreq);
40
41    M= controlloop(DS,{C2});
42    losses_wind(i) = (M.DS_dt_y - C1.yreq)'*(M.DS_dt_y - C1.yreq);
43    if losses_wind(i)>100
44      %  keyboard;
45    end
46end
47[mean(losses_plain), mean(losses_wind)]
48[std(losses_plain), std(losses_wind)]
Note: See TracBrowser for help on using the browser.