root/applications/bdmtoolbox/tutorial/estimation/arx_test.m @ 586

Revision 586, 1.7 kB (checked in by smidl, 15 years ago)

redesign of ctrl LQ control for arx

Line 
1theta = [0.8, -0.3, 0.4, 1.0;...
2         0.0, 0.0, 0.0, 0.0];
3R = [0.1, 0.0; 0.0, 1.0];
4
5
6y = struct('class','RV','names',{{'y'}});
7y.class = 'RV';
8y.names= {'y'};
9
10u = struct('class','RV','names',{{'u'}});
11%yu = struct('class','RV','names',{{'y','u'}});
12rgr= struct('class','RV',...
13        'names',{{'y', 'y','y','u'}},...
14                'times' , [-1, -2, -3, -1]);
15
16%Data generating system
17system = struct(...
18        'class', 'ArxDS',...
19        'y', struct('class','RV','names',{{'y', 'u'}}),...
20        'u',  struct('class','RV','names',{{}}),...
21        'rgr', rgr,...
22        'theta', theta,...
23        'offset',  [0.0, 0.0],...
24        'r', R,...
25        'opt', 'L_theta');
26
27% store results
28% logger = struct(...
29%       'class','dirfilelog',...
30%       'dirname','arx_test',...
31%       'maxlen',  1000);
32
33A1.class = 'ARX';
34A1.y = y;
35A1.rgr = rgr;
36A1.options ='logbounds,logll';
37
38estimators = { A1};
39
40%experiment description
41ndat = 90;
42experiment.ndat = ndat;
43
44M=estimator(system,estimators,experiment);%,logger);
45
46%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
47% plot results
48
49subplot(1,2,1);
50hold off
51plot([M.tth(1:ndat,1:2:end) ],'-.');
52title(' Regression parameters \theta')
53hold on
54plot(M.mean_theta(1:ndat,:));
55co = get(gca,'ColorOrder');
56for i=1:4
57    ind =1:10:ndat;
58    h=errorbar(ind,M.mean_theta(ind,i),...
59    M.mean_theta(ind,i)-M.lb_theta(ind,i),M.mean_theta(ind,i)-M.ub_theta(ind,i),'.');
60    set(h,'color',co(i,:));
61end
62
63set(gca,'YLim',[-0.7,2]);
64
65subplot(1,2,2);
66hold off
67plot([M.rR(1:ndat) ],'-.');
68title('Variance parameters r')
69hold on
70plot(M.mean_r(1:ndat,:));
71co = get(gca,'ColorOrder');
72ind =1:10:ndat;
73for i=1:size(M.mean_r, 2)
74    h=errorbar(ind,M.mean_r(ind,i),...
75    M.mean_r(ind,i)-M.lb_r(ind,i),M.mean_r(ind,i)-M.ub_r(ind,i),'.');
76    set(h,'color',co(i,:));
77end
Note: See TracBrowser for help on using the browser.