www.pudn.com > Closid30.rar > CLMODEST.M, change:1998-09-17,size:4738b


function clmodest(option) 
% function clmodest(option) 
 
% Model estimation step 
% OPTION indicates the identification method being used: 
% 1   Two-stage 
% 2   Indirect 
% 3   Tailor-made 
% 4   IV 
% 5   Coprime factors 
% 6   Dual-Youla 
% 7   Non-parametric 
 
% Functions called: cl2sitb, spa, cllight, clsplit, dlsim, cltailoe, 
%                   clidcfoe 
 
% 28-05-1996 
% (c) Douwe de Vries, Paul Van den Hof 
% Mechanical Engineering Systems and Control Group 
% Delft University of Technology 
% Last update: 19-05-1998 
%              20-08-1998: correction non-param estimated model conversion 
%              16-09-1998: Adapted to prepare validation data to be copied 
%                          to SITB validation data icon. 
 
global CLIDmods 
 
% Set the name strings of the data and method to be 
% copied to SITB: 
if option==1 
   DataName='twost'; 
   DataDesc='Reconstructed data for two-stage closed loop identification'; 
elseif option==2 
   DataName='indir'; 
   DataDesc='Reconstructed data for indirect closed loop identification'; 
elseif option==3 
   DataName='tailm'; 
   DataDesc='Reconstructed data for tailor-made closed loop identification'; 
elseif option==5 
   DataName='copr'; 
   DataDesc='Reconstructed data for coprime factors closed loop identification'; 
elseif option==6 
   DataName='youla'; 
   DataDesc='Reconstructed data for dual-Youla closed loop identification'; 
end 
% 
 
% Get the appropriate signals: 
[dat,tit,info,p]=clobjget('datfe'); 
tsamp=p(2,1); 
% 
% Construct the appropriate i/o signals for the estimation step: 
if option~=5 & option~=7 
  u_c_f=dat(:,2); 
  y_c_f=dat(:,1);  
  if option==4 
    r_c_f=dat(:,3); 
  end 
else 
  u_c_f=dat(:,3); 
  y_c_f=dat(:,[1 2]);  
end 
 
%Added 16-09-1998:%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
%For methods that use SITB, construct a validation data set to be 
%copied to the SITB validation data board 
if option==1 | option==2 | option==5 | option==6 
  [datv,titv,infov,pv]=clobjget('datfv'); 
  tsampv=pv(2,1); 
  if option==5 
    u_c_fv=datv(:,3); 
    y_c_fv=datv(:,[1 2]);  
  else 
    u_c_fv=datv(:,2); 
	y_c_fv=datv(:,1); 
  end 
end 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 
% Perform preparations for tailor-made identification 
if option==3 
  nn=get(findobj('tag','TAILORORDER'),'string'); 
  eval(['nn=[',nn,'];']); 
  C=clobjget('C'); 
  [th]=cltailoe([y_c_f u_c_f],nn,C,[],tsamp); 
     
%  MS=modstruc(nan*a,nan*b,nan*c,nan*d,0*b); 
%  parval=[reshape(a',1,n*n) reshape(b',1,n) reshape(c',1,n) reshape(d',1,1)]; 
%  th=ms2th(MS,'d',parval,[],tsamp); 
 
  set(findobj('tag','TAILORORDER'),'userdata',th) 
  cllight(2) 
% 
% Apply IV method: 
elseif option==4 
  nn=get(findobj('tag','IVORDER'),'string'); 
  eval(['nn=[',nn,'];']); 
  th=ivx([y_c_f u_c_f],nn,r_c_f,[],tsamp); 
  set(findobj('tag','IVORDER'),'userdata',th) 
  cllight(2) 
% 
% Apply Cop.fac. ID with (local) OE method: 
elseif option==5 & get(findobj('tag','CLIDENT'),'value')==2, 
  nn=get(findobj('tag','CFOEORDER'),'string'); 
  eval(['nn=[',nn,'];']); 
  th=clidcfoe([y_c_f u_c_f],nn,tsamp); 
  set(findobj('tag','CLIDENT'),'userdata',th) 
  cllight(2) 
% 
% Apply nonparametric identification 
elseif option==7 
  M=get(findobj('tag','WINDOWLENGTH'),'string'); 
  M=eval(M); 
  G=spa([y_c_f u_c_f],[M M],[],[],tsamp);  
  Nw=length(G); 
  mG=G(2:Nw,2)./G(2:Nw,7);fG=G(2:Nw,4)-G(2:Nw,9); 
  if ~isempty(findobj('tag','SPECESTWIN')) 
    h=findobj('tag','SPECESTWIN'); 
    figure(h) 
  else   
    figure('name','Spectral estimates','numbertitle','off',... 
     'pos',[521    61   461   350],'color',[0.5 0.5 0.5],... 
     'menubar','none','DefaultAxesColor',[0 0 0],... 
     'DefaultAxesFontsize',10,'tag','SPECESTWIN'); 
  end  
  w=G(2:Nw,1); 
  loglog(w,G(2:Nw,2),'--',w,G(2:Nw,7),'-',w,mG,':') 
  title('Spectral estimate tranfers x->u (solid), x->y (dashed) and u->y (:)') 
  xlabel('frequency (rad/sec)')  
  zoom on 
% Correction 20/08/98:%%%%%%%%%%%%%%%%%%%%%% 
  Gquot(1,:) = [101 1 21]; 
  Gquot(2:Nw,:) = [w mG fG]; 
  set(findobj('tag','WINDOWLENGTH'),'userdata',Gquot) 
% set(findobj('tag','SPECESTWIN'),'userdata',G) 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
  cllight(2) 
% 
% For all other methods: convert data to SITB data-board 
else 
  ident 
%  cl2sitb(y_c_f,u_c_f,DataDesc,DataName,'u_c_f','y_c_f'); 
% Construct name of validation data set to be copied to SITB: 
  Datan=[DataName '-e']; 
  if CLIDmods(58,1)==CLIDmods(59,1)  %% Estimation data=validation data 
    Datanv=Datan; 
  else 
    Datanv=[DataName '-v']; 
  end 
  cl2sitb(y_c_f,u_c_f,DataDesc,Datan,'u_c_f','y_c_f',... 
          y_c_fv,u_c_fv,DataDesc,Datanv,'u_c_fv','y_c_fv'); 
  cllight(2) 
end