Revision 744, 1.1 kB
(checked in by smidl, 15 years ago)
|
Working unitsteps and controlloop + corresponding fixes
|
Rev | Line | |
---|
[744] | 1 | % name random variables |
---|
| 2 | y = RV({'y'},1); |
---|
| 3 | u1 = RV({'u1'},1); |
---|
| 4 | u2 = RV({'u2'},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,u1,u2], [-3, 0, 0]); |
---|
| 10 | fy.A = [0.5, -0.9, 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.rv = y; |
---|
| 20 | A1.rgr = RVtimes([y,u1],[-3,0]) ; % correct structure is {y,y} |
---|
| 21 | A1.options ='logbounds,logll'; |
---|
| 22 | A1.frg = 0.95; |
---|
| 23 | |
---|
| 24 | A2=A1; |
---|
| 25 | A2.rgr = RVtimes([y,u2],[-3,0]) ; % correct structure is {y,y} |
---|
| 26 | |
---|
| 27 | |
---|
| 28 | C1.class = 'LQG_ARX'; |
---|
| 29 | C1.ARX = A1; |
---|
| 30 | C1.Qu = 0.1*eye(1); |
---|
| 31 | C1.Qy = 1*eye(1); |
---|
| 32 | C1.yreq = 1; |
---|
| 33 | C1.horizon = 100; |
---|
| 34 | |
---|
| 35 | C2=C1; |
---|
| 36 | C2.ARX = A2; |
---|
| 37 | |
---|
| 38 | M= controlloop(DS,{C1,C2}); |
---|
| 39 | |
---|
| 40 | |
---|
| 41 | %%%%%%%%%%%%%%%%%%%%%%%%%%%% |
---|
| 42 | % PLOTS |
---|
| 43 | |
---|
| 44 | figure(1); |
---|
| 45 | hold off |
---|
| 46 | subplot(1,2,1); |
---|
| 47 | plot(M.DS_y); |
---|
| 48 | subplot(1,2,2); |
---|
| 49 | plot(M.DS_u1); hold on; |
---|
| 50 | plot(M.DS_u2); |
---|
| 51 | |
---|
| 52 | figure(2); |
---|
| 53 | hold off |
---|
| 54 | plot(M.Ctrl0_apost_mean_theta); |
---|
| 55 | hold on |
---|
| 56 | plot(M.Ctrl0_apost_ub_theta,':'); |
---|
| 57 | plot(M.Ctrl0_apost_lb_theta,':'); |
---|
| 58 | set(gca,'YLim',[-4,2]); |
---|
| 59 | |
---|
| 60 | figure(3); |
---|
| 61 | hold off |
---|
| 62 | plot(M.Ctrl1_apost_mean_theta); |
---|
| 63 | hold on |
---|
| 64 | plot(M.Ctrl1_apost_ub_theta,':'); |
---|
| 65 | plot(M.Ctrl1_apost_lb_theta,':'); |
---|
| 66 | set(gca,'YLim',[-2,3]); |
---|