Revision 968, 0.9 kB
(checked in by smidl, 14 years ago)
|
New mexes + corrected tutorial
|
Line | |
---|
1 | clear all |
---|
2 | % name random variables |
---|
3 | y = RV({'y'},1); |
---|
4 | u = RV({'u'},1); |
---|
5 | |
---|
6 | % create f(y_t| y_{t-3}, u_{t-1}) |
---|
7 | fy.class = 'mlnorm<ldmat>'; |
---|
8 | fy.rv = y; |
---|
9 | fy.rvc = RVtimes([y,u], [-3, -1]); |
---|
10 | fy.A = [0.5, -0.9]; |
---|
11 | fy.const = 0; |
---|
12 | fy.R = 1e-2; |
---|
13 | |
---|
14 | DS.class = 'PdfDS'; |
---|
15 | DS.pdf = fy; |
---|
16 | |
---|
17 | % create ARX estimator |
---|
18 | A1.class = 'ARX'; |
---|
19 | A1.yrv = y; |
---|
20 | A1.rgr = RVtimes([y,u],[-3,-1]) ; % correct structure is {y,y} |
---|
21 | A1.log_level ='logbounds,logevidence'; |
---|
22 | |
---|
23 | C1.class = 'LQG_ARX'; |
---|
24 | C1.ARX = A1; |
---|
25 | C1.Qu = 100*eye(1); |
---|
26 | C1.Qy = 100*eye(1); |
---|
27 | C1.yreq = 1; |
---|
28 | C1.horizon = 10; |
---|
29 | |
---|
30 | C2 = C1; |
---|
31 | C2.windsurfer = 1; |
---|
32 | |
---|
33 | N = 10; |
---|
34 | losses_plain=zeros(1,N); |
---|
35 | losses_wind =zeros(1,N); |
---|
36 | |
---|
37 | for 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 |
---|
46 | end |
---|
47 | [mean(losses_plain), mean(losses_wind)] |
---|
48 | [std(losses_plain), std(losses_wind)] |
---|