Documentation of iduiinsm


Global Index (short | long) | Local contents | Local Index (short | long)


Function Synopsis

handlenr=iduiinsm(Model,model_info,model_name,active,axinfo)

Help text

IDUIINSM Handles the insertion of models into the Model Summary Board
      Model:      The actual model, in theta-format or CRA or SPA model
      model_info: The asociated model information
      model_name: The name (a string) of the model.
      active:     If active==1 then the model should become active immediately
      HANDLENR:   The handle number of the model pushbutton

Cross-Reference Information

This function calls This function is called by

Listing of function iduiinsm

function handlenr=iduiinsm(Model,model_info,model_name,active,axinfo)

%   L. Ljung 4-4-94
%   Copyright (c) 1986-98 by The MathWorks, Inc.
%   $Revision: 3.8 $  $Date: 1997/12/02 03:41:14 $

global  XIDplotw XIDsumb  XIDparest XIDcounters XIDsbmen
XIDcounters(5)=1; 
if isempty(Model),peflag=1;else peflag=0;end
if peflag
   mess=str2mat(...
     'WARNING: There were numerical problems to compute the model.',...
     '      The model order might have been too high, or the input',...
     '      signal is not persistently exciting.',...
     '      Use other input or lower model orders.',...
     '      No model inserted.');
   warndlg(mess);
   return
end

if nargin < 4,active=1;end
if active,iduistat('Model being inserted ...');end
if nargin<5
   [axh,texh,linh]=idnextw('model');
else
  [axh,texh,linh]=idnextw('model',axinfo(1),axinfo(2:5),axinfo(6:8));
  if isempty(linh),   [axh,texh,linh]=idnextw('model');end
end

tag=get(axh,'tag');eval('set(XIDparest(3),''userdata'',tag);','')
modnr=eval(tag(6:length(tag)));
theta_model=1;
 
if strcmp(deblank(model_info(1,:)),'imported')
   T=num2str(gett(Model));
   model_info(2,1:length(T))=T;
   nu=int2str(Model(1,3));
   model_info(6,1:length(nu))=nu;
   if isthss(Model),ny=int2str(Model(1,4));else ny=int2str(1);end
   model_info(3,1:length(ny))=ny;
   nustr=[];nystr=[];
   for ku=1:eval(nu),nustr=[nustr,int2str(ku),' '];end
   for ky=1:eval(ny),nystr=[nystr,int2str(ky),' '];end
   model_info([7],1:length(nystr))=nystr;
   if ~isempty(nustr),   model_info([8],1:length(nustr))=nustr;end
   model_info=setstr(model_info);
end
[ny,nu]=iduiiono('old',model_info,'mod');
[nr,nc]=size(Model);if nc==1,theta_model=0;end
type=model_info(1,1:3);
if type=='cra'|type=='spa'
    theta_model=0;
else 
    if strcmp(get(XIDplotw(3,2),'enable'),'off')
       set(XIDplotw(2:7,2),'enable','on')
    end
end
if type=='cra' 
     set(XIDplotw([5],2),'enable','on'),
     lpl=Model(1:min(20,length(Model(:,1))),1);
elseif type=='spa' 
     set(XIDplotw([2,7],2),'enable','on'),
     lpl=Model(2:length(Model(:,2)),2);
else
    if ~theta_model,Modelth=iduicalc('unpack',Model);else Modelth=Model;end
    pars=th2par(Modelth);
    peflag=any(isnan(pars))|any(isinf(pars));
    if peflag
      mess=str2mat(...
     'WARNING: There were numerical problems to compute the model.',...
     '      The model order might have been too high, or the input',...
     '      signal is not persistently exciting.',...
     '      Use other input or lower model orders.',...
     '      No model inserted.');
      warndlg(mess);
      return
    end
    lpl=idsim([[1;zeros(19,1)],zeros(20,max(ny+nu-1,0))],Modelth,1);
end

lpl=lpl(:,1);

if XIDcounters(3)<nu|XIDcounters(4)<ny
   XIDcounters([3 4])=max(XIDcounters([3 4]),[nu ny]);
   iduiiono('set',XIDcounters([3 4]))
end
set(axh,'vis','off')
set(linh,'UserData',Model,'tag','modelline')
set(texh,'String',model_name,'vis','on')
handlenr=axh;
set(texh,'UserData',model_info)

set(linh,'xdata',1:length(lpl),'ydata',lpl,'vis','off');
Plotcolors=idlayout('plotcol');
axescolor=Plotcolors(4,:);

ylim = [2*min(lpl)-max(lpl) max(lpl)];
if ylim(1)>=ylim(2),
      ylim = [ylim(1)-1 ylim(2)+1];
end

set(axh,'ylim',ylim,'xlim',[1 length(lpl)],...
    'color',axescolor);

if theta_model
 if isthss(Model)
    [par,P,dum]=th2par(Model);ny=Model(1,4);A=th2ss(Model);
     
    if ~(any(isnan(P(:)))|any(isinf(P(:))))
    if ~(isempty(P)|norm(P)==0)
       axes(axh)
       text('vis','off','tag','ny0','userdata',length(A)*ny*length(par));
    end
    end
  end
end
if active,
    set(linh,'linewidth',3);
end   
set(linh,'vis','on')
set(axh,'vis','on')

if active,
    Figno=fiactha(XIDplotw(2:7,2))+1;
    iduimod(Figno,modnr,[])
    set(XIDsbmen([3 5]),'enable','on')
    if strcmp(get(XIDsbmen(1),'tag'),'open')
      [label,acc]=menulabel('&Merge session... ^o');
      set(XIDsbmen(1),'label',label,'tag','merge');
    end
    iduistat(['Model ',model_name,' inserted.',...
         '  Double click on icon (right mouse) for text information.'])

end