www.pudn.com > Closid30.rar > Clobjins.m, change:1998-09-17,size:7552b


function clobjins(model,option,title,info,p) 
% clobjins(model,option,title,info,p) 
% 
% Inserts data, model or controller in the data/model/controller board. 
% 
 
% model    Data for option 'Data',  
%          Plant model for option 'P' in either  
%           theta-format (p=1) or freqfunc-format (p=0); 
%          Controller or auxiliary model in system 
%            format for option 'C' or 'X' or others. 
%          Index number of data axis for options 'datw' or 'datv' 
% option   'data' for data 
%          'P'    for estimated plant in theta format 
%          'Pnd'  for estimated plant coprime factors 
%          'C'    for controller 
%          'Cnd'  for controller coprime factors 
%          'X'    for auxiliary model 
%          'Xnd'  for auxiliary model coprime factors 
%          'datre'for estimation excitation signal 
%          'datrv' for validation excitation signal 
%          'datfe' for filtered estimation data 
%          'datfv' for filtered validation data 
%          'datw' for working data 
%          'datv' for validation data 
% title    Name of the object 
% info     Information on the object 
% p        In case of object 'P': parametric plant model (p=1) 
%                                 or nonparametric model (p=0); 
%                                 By default, p=1. 
%          In case of object 'data', 'datre', 'datrv', 'datfe' or 'datfv':  
%                    p = [rng1 rngN; tsamp tstart]; 
 
% Functions called: clsplit,th2ss,clerrdia,dbode,getff 
 
% 14-06-96 
% (c) Douwe de Vries, Paul Van den Hof 
% Mechanical Engineering Systems and Control Group 
% Delft University of Technology 
% Last update: 19-05-1998 
%              16-07-1998: Correction Bode icon plots to contain plant dynamics only. 
%              26-08-1998: Correction Bode icon plots to be plotted with tsamp=1. 
%              16-09-1998  F, datc --> datre, datrv  
 
global CLIDmods 
 
%nonpar=0; 
if strcmp(option,'data') 
   strerr=str2mat(' ERROR INSERTING DATA:',' data board full'); 
   mkplt=1; 
   ix=1; 
elseif strcmp(option,'P') 
   strerr=str2mat(' ERROR INSERTING MODEL:',' model board full'); 
   mkplt=1;  
   %[A,B,C,D]=th2ss(model); 
   ix=2; 
elseif strcmp(option,'Pnd') 
   strerr=str2mat(' ERROR INSERTING MODEL FACTORS:',' model factors board full'); 
   mkplt=0; 
   ix=3; 
elseif strcmp(option,'C') 
   strerr=str2mat(' ERROR INSERTING CONTROLLER:',' controller board full'); 
   mkplt=1;  
   %[A,B,C,D]=clsplit(model); 
   ix=4; 
elseif strcmp(option,'Cnd') 
   strerr=str2mat(' ERROR INSERTING CONTROLLER FACTORS:',' controller factors board full'); 
   mkplt=0; 
   ix=5; 
elseif strcmp(option,'X') 
   strerr=str2mat(' ERROR INSERTING AUXILIARY MODEL:',' auxiliary model board full'); 
   mkplt=0; 
   ix=6; 
elseif strcmp(option,'Xnd') 
   strerr=str2mat(' ERROR INSERTING AUXILIARY MODEL FACTORS:',' auxiliary model factors board full'); 
   mkplt=0; 
   ix=7; 
elseif strcmp(option,'datre') 
   strerr=str2mat(' ERROR INSERTING ESTIMATION EXCITATION SIGNAL:',' excitation board full'); 
   mkplt=0; 
   ix=8; 
elseif strcmp(option,'datrv') 
   strerr=str2mat(' ERROR INSERTING VALIDATION EXCITATION SIGNAL:',' excitation board full'); 
   mkplt=0; 
   ix=9; 
elseif strcmp(option,'datfe') 
   strerr=str2mat(' ERROR INSERTING FILTERED ESTIMATION DATA:',' filtered data board full'); 
   mkplt=0; 
   ix=10; 
elseif strcmp(option,'datfv') 
   strerr=str2mat(' ERROR INSERTING FILTERED VALIDATION DATA:',' filtered data board full'); 
   mkplt=0; 
   ix=11; 
elseif strcmp(option,'datw') 
   strerr=str2mat(' '); 
   mkplt=1; 
   ix=12; 
elseif strcmp(option,'datv') 
   strerr=str2mat(' '); 
   mkplt=1; 
   ix=13; 
else 
   error('not a valid option') 
end 
 
if nargin<3 
   title=[]; 
end 
if nargin<4 
   info=[]; 
end 
if nargin<5 
   p=1; 
end 
if isempty(title) 
   title=option; 
end 
 
% If-loop added 11-09-1998 to allow working and validation data insert 
if (ix <=11) 
% ix indicates the category of object that is going to be inserted. 
% cm is the number of these objects that is allowed 
% ro+2 is the first row in CLIDmods that indicates the place where 
% the information should be stored.  
  ro=(ix-1)*5; 
  cm=CLIDmods(1,ix); 
  if cm==1 
    in=1;                             % replace old data 
  else 
    cm=[1:cm]; 
    in=find(CLIDmods(ro+3,cm)==0);    % find empty axes 
  end 
  if isempty(in) 
    clerrdia(strerr,1) 
    return 
  else 
    in=in(1); 
    axh=CLIDmods(ro+4,in); 
    texh=CLIDmods(ro+5,in); 
    linh=CLIDmods(ro+6,in); 
%   Find active axes: 
    ia=find(CLIDmods(ro+2,cm)==1); 
%   Find occupied axes: 
    ioc=find(CLIDmods(ro+3,cm)==1); 
    CLIDmods(ro+3,in)=1;              % set new axes to occupied 
    if ix==2 
      CLIDmods(57,in)=p; 
    end 
% 
%  Deactivate all formerly active objects except  
%  data, model and controller 
    if (ix~=1 & ix~=2 & ix~=4 & ~isempty(ia)) 
      CLIDmods(ro+2,ia)=0*ia; 
      set(CLIDmods(ro+6,ia),'linewidth',1); 
    end 
%  Activate newly added objects; 
%  Activation for data, model and controller only if it is the first 
%  one present. 
    CLIDmods(ro+2,in)=1; 
    if ((ix==1 | ix==2 | ix==4) & ~isempty(ioc)) 
      CLIDmods(ro+2,in)=0; 
    end 
% 
    set(linh,'UserData',model); 
    set(texh,'UserData',info); 
    set(texh,'String',title,'color','w'); 
    if (ix==1 | ix==8 | ix==9 | ix==10 | ix==11), 
      set(axh,'Userdata',p); 
    end 
 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
  end 
   
  % Added 11-09-1998 for the situation 'datw' and 'datv': 
else 
% store the appropriate information in CLIDmods   
  CLIDmods(46+ix,1)=model; 
% Read the appropriate data set: 
%  axh=CLIDmods(4,model); 
  texh=CLIDmods(5,model); 
  linh=CLIDmods(6,model); 
  color=get(linh,'color'); 
  model=get(linh,'Userdata'); 
  title=get(texh,'String'); 
  axh=CLIDmods(46+ix,2); 
  texh=CLIDmods(46+ix,3); 
  linh=CLIDmods(46+ix,4); 
  set(texh,'String',title,'color','w'); 
end 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
 
if mkplt 
  if (ix==1 | ix>=9)  
    dl=min(50,size(model,1)); 
    ll=model(1:dl,1); 
    set(axh,'ylim',[2*min(ll)-max(ll) max(ll)],'xlim',[0 dl],'color','k'); 
  else 
%%%%%%%Correction 26-08-1998 %%%%%%%%%%%% 
%      h=findobj('TAG','CLDATADES'); 
%      us=get(h,'Userdata'); 
%      tsamp=us(4,1); 
    tsamp=1; 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    if strcmp(option,'P') & p==1 
%        Correction for getting Bode plots based on plant model only: 
      [numx1,denx1]=th2tf(model,1); 
      [ll,phase,w]=dbode(numx1,denx1,tsamp); 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% 
    elseif strcmp(option,'P') & p==0 
      [w,ll,phase]=getff(model); 
    else 
      [A,B,C,D]=clsplit(model); 
      [ll,phase,w]=dbode(A,B,C,D,tsamp,1); 
    end 
    dl=size(ll,1); 
    set(axh,'ylim',[min(ll)/100 5*max(ll)],'xlim',[0 dl],'color','k'); 
  end 
  set(linh,'xdata',1:dl,'ydata',ll); 
%   set(linh,'linewidth',3); 
  set([linh axh texh],'vis','on') 
 
  if ix>=12  % For working/validation data have thin lines with right color 
    set(linh,'linewidth',1,'color',color); 
  elseif CLIDmods(ro+2,in)==0 
    set(linh,'linewidth',1); 
  elseif CLIDmods(ro+2,in)==1 
    set(linh,'linewidth',3); 
  end 
end 
% 
% If the first data set is inserted: copy the appropriate information to the 
% working data and validation data icons. 
%  Copy dataset to working and validation data if it is the first set inserted. 
if (ix==1 & isempty(ioc)) 
  CLIDmods(58,1)=in; 
  CLIDmods(59,1)=in; 
  clobjins(in,'datw'); 
  clobjins(in,'datv'); 
end