Show
Ignore:
Timestamp:
08/27/09 15:39:35 (15 years ago)
Author:
smidl
Message:

redesign of ctrl LQ control for arx

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • applications/bdmtoolbox/tutorial/estimation/arx_test.m

    r414 r586  
     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 
    16y = struct('class','RV','names',{{'y'}});  
     7y.class = 'RV'; 
     8y.names= {'y'}; 
     9 
    210u = struct('class','RV','names',{{'u'}});  
    3 yu = struct('class','RV','names',{{'y','u'}});  
     11%yu = struct('class','RV','names',{{'y','u'}});  
    412rgr= struct('class','RV',... 
    513        'names',{{'y', 'y','y','u'}},... 
     
    1220        'u',  struct('class','RV','names',{{}}),... 
    1321        'rgr', rgr,... 
    14         'theta', [0.8, -0.3, 0.4, 1.0; 
    15               0.0, 0.0, 0.0, 0.0],... 
     22        'theta', theta,... 
    1623        'offset',  [0.0, 0.0],... 
    17         'r', [0.1, 0.0; 0.0, 1.0],... 
     24        'r', R,... 
    1825        'opt', 'L_theta'); 
    1926 
    20 %store results 
    21 logger = struct(... 
    22         'class','dirfilelog',... 
    23         'dirname','arx_test',... 
    24         'maxlen',  1000); 
     27% store results 
     28% logger = struct(... 
     29%       'class','dirfilelog',... 
     30%       'dirname','arx_test',... 
     31%       'maxlen',  1000); 
    2532 
    26 estimators = { 
    27         struct('class','ARX',... 
    28         'y', y,... 
    29         'rgr', rgr) 
    30 }; 
     33A1.class = 'ARX'; 
     34A1.y = y; 
     35A1.rgr = rgr; 
     36A1.options ='logbounds,logll'; 
     37 
     38estimators = { A1}; 
    3139 
    3240%experiment description 
    33 experiment.ndat = 9000; 
     41ndat = 90; 
     42experiment.ndat = ndat; 
    3443 
    3544M=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