Global Index (short | long) | Local contents | Local Index (short | long)
outarg=iduifile(arg,file,dum)
IDUIFILE Handles file operations in ident. Arguments: load_data Opens the dialog box for importing datavariable load_iodata Opens the dialog box for importing data in i/o form load_model Opens the dialog box for importing models load_mat Loads the selected mat file done_data Final operations when inserting data reset Resets the dialog's different boxes insert Inserts i/o data into summary board test1 Tests if sampling interval reasonable This function works in symbiosis with the script file IDUIFSCR that does some of the operation in the workspace.
This function calls | This function is called by |
---|---|
function outarg=iduifile(arg,file,dum) % L. Ljung 4-4-94 % Copyright (c) 1986-98 by The MathWorks, Inc. % $Revision: 3.6 $ $Date: 1997/12/02 03:43:06 $ global XIDhdat XIDhload XIDsumb XIDlayout %iduistat('') % Removes Compiling... message if strcmp(arg,'load_iodata') cb1='iduipoin(1);iduistat(''Compiling...'');'; cb2='iduipoin(1);'; cb3='iduipoin(2);'; FigName=idlaytab('figname',19); if ~figflag(FigName,0) iduistat('Opening the import dialog box ...') layout butw=mStdButtonWidth;buth=mStdButtonHeight; FigW=iduilay2(2); XIDhload(1,1)=figure('vis','off',... 'NumberTitle','off','Name',FigName,... 'Integerhandle','off','HandleVisibility','callback',... 'Color',get(0,'DefaultUIControlBackgroundColor'),'tag','sitb19'); set(XIDhload(1,1),'Menubar','none'); strload=[]; % LEVEL 1 pos = iduilay1(FigW,4,2); uicontrol(XIDhload(1,1),'pos',pos(1,:),'style','frame'); uicontrol(XIDhload(1,1),'pos',pos(2,:),... 'style','push','string','Import','callback',... [cb1,'eval(''XIDarg=''''prep_dataio'''';,iduifscr;'');',... 'eval(''iduifile(''''insert'''');''),',cb3]); uicontrol(XIDhload(1,1),'pos',pos(3,:),'style',... 'push','string','Reset','callback','iduifile(''reset'',1)'); uicontrol(XIDhload(1,1),'pos',pos(4,:),... 'style','push','string','Close',... 'callback','set(gcf,''vis'',''off'')'); uicontrol(XIDhload(1,1),'pos',pos(5,:),... 'style','push','string','Help',... 'callback','iduihelp(''iduiimp2.hlp'',''Importing Data'');'); % LEVEL 2 Frame for Data Info lev2=pos(1,2)+pos(1,4); pos = iduilay1(FigW,18,9,lev2,4,[2 2]/2); uicontrol(XIDhload(1,1),'pos',pos(1,:),'style','frame'); XIDhload(1,12) = uicontrol(XIDhload(1,1),'pos',... [pos(18,1:2) FigW-2*pos(18,1) 4*buth+3*4],... 'style','edit',... 'HorizontalAlignment','left',... 'String','','max',2,'Backgroundcolor','w'); uicontrol(XIDhload(1,1),'pos',... pos(10,:),'style','text',... 'HorizontalAlignment','left',... 'string','Notes:'); uicontrol(XIDhload(1,1),'pos',pos(4,:),'style',... 'text','string','Data name:',... 'HorizontalAlignment','left'); XIDhload(1,4) = uicontrol(XIDhload(1,1),'pos',pos(5,:),'style','edit',... 'HorizontalAlignment','left',... 'String','mydata','Backgroundcolor','w'); uicontrol(XIDhload(1,1),'pos',pos(6,:),... 'String','Starting time:','style','text',... 'horizontalalignment','left'); XIDhload(1,8) = uicontrol(XIDhload(1,1),'pos',pos(7,:),... 'style','edit','String','1','tag','startt',... 'HorizontalAlignment','left','callback','iduifile(''test1'');',... 'Backgroundcolor','w'); uicontrol(XIDhload(1,1),'pos',pos(8,:),... 'String','Samp. interv.:','style','text',... 'horizontalalignment','left'); XIDhload(1,6) = uicontrol(XIDhload(1,1),'pos',pos(9,:),'tag','tsamp',... 'HorizontalAlignment','left','callback','iduifile(''test1'');',... 'style','edit','String','1','Backgroundcolor','w'); uicontrol(XIDhload(1,1),'pos',[pos(2,1:2) ... FigW-2*(mEdgeToFrame+mFrameToText) pos(2,4)],... 'style','text','string','Optional Data Information',... 'HorizontalAlignment','center','fontweight','bold'); % LEVEL 3 Frame for Variable info lev3=pos(1,2)+pos(1,4); pos = iduilay1(FigW,8,4,lev3,4,[1 3]/2); uicontrol(XIDhload(1,1),'pos',pos(1,:),'style','frame'); uicontrol(XIDhload(1,1),'pos',pos(6,:),... 'HorizontalAlignment','left',... 'style','text','string','Input:') XIDhload(1,11)=... uicontrol(XIDhload(1,1),'pos',pos(7,:),... 'style','edit','Backgroundcolor','w',... 'HorizontalAlignment','left'); uicontrol(XIDhload(1,1),'pos',pos(8,:),... 'style','text','string','Output:',... 'HorizontalAlignment','left'); XIDhload(1,13)=... uicontrol(XIDhload(1,1),'pos',pos(9,:),... 'style','edit','Backgroundcolor','w',... 'HorizontalAlignment','left'); uicontrol(XIDhload(1,1),'pos',pos(4,:)+[0 0 1.5*butw 0],'style','text',... 'HorizontalAlignment','left',... 'string',... 'Enter workspace variable names.'); uicontrol(XIDhload(1,1),'pos',... [pos(2,1:2) FigW-2*(mEdgeToFrame+mFrameToText) pos(2,4)],... 'style','text','string',... 'Input Output Variables','fontweight','bold'); FigWH=[FigW pos(1,2)+pos(1,4)+mEdgeToFrame]; ScreenPos = get(0,'ScreenSize'); Sumbpos=get(XIDsumb(1),'pos'); FigXY=max([0,0],(Sumbpos(1:2)+Sumbpos(3:4)-[0,FigWH(2)])); FigXY=min(FigXY,ScreenPos(3:4)-FigWH); FigPos=[FigXY FigWH]; set(XIDhload(1,1),'pos',FigPos); set(get(XIDhload(1,1),'children'),'units','norm'); if length(XIDlayout)>18 if XIDlayout(19,3) eval('set(XIDhload(1,1),''pos'',XIDlayout(19,1:4));','') end end if nargin<3, set(XIDhload(1,1),'vis','on'),end iduistat('Enter input and output variable names.') end %if figflag elseif strcmp(arg,'load_data') cb1='iduipoin(1);iduistat(''Compiling...'');'; cb2='iduipoin(1);'; cb3='iduipoin(2);'; FigName=idlaytab('figname',18); if ~figflag(FigName,0) iduistat('Opening the import dialog box ...') layout butw=mStdButtonWidth; buth=mStdButtonHeight; FigW = iduilay2(2); XIDhload(3,1)=figure('vis','off',... 'NumberTitle','off','Name',FigName,... 'Integerhandle','off','HandleVisibility','callback',... 'Color',get(0,'DefaultUIControlBackgroundColor'),'tag','sitb18'); set(XIDhload(3,1),'Menubar','none'); strload=[]; % LEVEL 1 pos = iduilay1(FigW,4,2); uicontrol(XIDhload(3,1),'pos',pos(1,:),'style','frame'); uicontrol(XIDhload(3,1),'pos',pos(2,:),... 'style','push','string','Import','callback',... [cb1,'XIDarg=''insert_data'';eval(''iduifscr;''),',cb3]); uicontrol(XIDhload(3,1),'pos',pos(3,:),'style',... 'push','string','Reset','callback','iduifile(''reset'',3)'); uicontrol(XIDhload(3,1),'pos',pos(4,:),... 'style','push','string','Close',... 'callback','set(gcf,''vis'',''off'')'); uicontrol(XIDhload(3,1),'pos',pos(5,:),... 'style','push','string','Help',... 'callback','iduihelp(''iduiimp1.hlp'',''Importing Data'');'); % LEVEL 2 Frame for Data Info lev2=pos(1,2)+pos(1,4); pos = iduilay1(FigW,18,9,lev2,4,[2 2]/2); uicontrol(XIDhload(3,1),'pos',pos(1,:),'style','frame'); XIDhload(3,12) = uicontrol(XIDhload(3,1),'pos',... [pos(18,1:2) FigW-2*pos(18,1) 4*buth+3*4],... 'style','edit',... 'HorizontalAlignment','left',... 'String','','max',2,'Backgroundcolor','w'); uicontrol(XIDhload(3,1),'pos',... pos(10,:),'style','text',... 'HorizontalAlignment','left',... 'string','Notes:'); uicontrol(XIDhload(3,1),'pos',pos(4,:),'style',... 'text','string','No of outputs:',... 'HorizontalAlignment','left'); XIDhload(3,10) = uicontrol(XIDhload(3,1),'pos',pos(5,:),'style','edit',... 'HorizontalAlignment','left',... 'String','1','Backgroundcolor','w'); uicontrol(XIDhload(3,1),'pos',pos(6,:),... 'String','Starting time:','style','text',... 'horizontalalignment','left'); XIDhload(3,8) = uicontrol(XIDhload(3,1),'pos',pos(7,:),... 'style','edit','String','1','tag','startt',... 'HorizontalAlignment','left','callback','iduifile(''test1'');',... 'Backgroundcolor','w'); uicontrol(XIDhload(3,1),'pos',pos(8,:),... 'String','Samp. interv.:','style','text',... 'horizontalalignment','left'); XIDhload(3,6) = uicontrol(XIDhload(3,1),'pos',pos(9,:),'tag','tsamp',... 'HorizontalAlignment','left','callback','iduifile(''test1'');',... 'style','edit','String','1','Backgroundcolor','w'); uicontrol(XIDhload(3,1),'pos',[pos(2,1:2) ... FigW-2*(mEdgeToFrame+mFrameToText) pos(2,4)],... 'style','text','string','Optional Data Information',... 'HorizontalAlignment','center','fontweight','bold'); % LEVEL 3 Frame for Variable info lev3=pos(1,2)+pos(1,4); pos = iduilay1(FigW,5,5,lev3,4,4/2); uicontrol(XIDhload(3,1),'pos',pos(1,:),'style','frame'); uicontrol(XIDhload(3,1),'pos',pos(2,:),'style','text','string',... 'Data Variable','Fontweight','bold'); uicontrol(XIDhload(3,1),'pos',pos(5,:)+[0 0 0 2*buth],'style','text',... 'HorizontalAlignment','left',... 'String',['Enter below the name of a workspace variable. Its '... 'first column(s) should contain the data outputs and '... 'the next column(s) should contain the data inputs']) XIDhload(3,4) = uicontrol(XIDhload(3,1),'pos',... pos(6,:),'style','edit',... 'HorizontalAlignment','left',... 'String','','Backgroundcolor','w','callback',... [cb1,'XIDarg=''prep_data'';,iduifscr;',cb3]); FigWH=[FigW pos(1,2)+pos(1,4)+mEdgeToFrame]; ScreenPos = get(0,'ScreenSize'); Sumbpos=get(XIDsumb(1),'pos'); FigXY=max([0,0],(Sumbpos(1:2)+Sumbpos(3:4)-[0,FigWH(2)])); FigXY=min(FigXY,ScreenPos(3:4)-FigWH); FigPos=[FigXY FigWH]; set(XIDhload(3,1),'pos',FigPos); if length(XIDlayout)>18 if XIDlayout(18,3) eval('set(XIDhload(3,1),''pos'',XIDlayout(18,1:4));','') end end if nargin<3, set(XIDhload(3,1),'vis','on'),end set(get(XIDhload(3,1),'children'),'units','norm'); iduistat('Enter data variable name.') end elseif strcmp(arg,'load_model') cb1='iduipoin(1);iduistat(''Compiling...'');'; cb2='iduipoin(1);'; cb3='iduipoin(2);'; FigName=idlaytab('figname',17); if ~figflag(FigName,0) iduistat('Opening the import dialog box ...') layout butw=mStdButtonWidth; buth=mStdButtonHeight; FigW=iduilay2(2); XIDhload(2,1)=figure('vis','off',... 'NumberTitle','off','Name',FigName,... 'Integerhandle','off','HandleVisibility','callback',... 'Color',get(0,'DefaultUIControlBackgroundColor'),'tag','sitb17'); set(XIDhload(2,1),'Menubar','none'); strload=[]; % LEVEL 1 pos = iduilay1(FigW,4,2); uicontrol(XIDhload(2,1),'pos',pos(1,:),'style','frame'); uicontrol(XIDhload(2,1),'pos',pos(2,:),... 'style','push','string','Import','callback',... [cb1,'XIDarg=''insert_model'';iduifscr;',cb3]); uicontrol(XIDhload(2,1),'pos',pos(3,:),'style',... 'push','string','Reset','callback','iduifile(''reset'',2)'); uicontrol(XIDhload(2,1),'pos',pos(4,:),... 'style','push','string','Close',... 'callback','set(gcf,''vis'',''off'')'); uicontrol(XIDhload(2,1),'pos',pos(5,:),... 'style','push','string','Help',... 'callback','iduihelp(''iduiimpm.hlp'',''Importing Models'');'); % LEVEL 2 Frame for Data Info lev2=pos(1,2)+pos(1,4); pos = iduilay1(FigW,5,5,lev2,4,4/2); uicontrol(XIDhload(2,1),'pos',pos(1,:),'style','frame'); XIDhload(2,12) = uicontrol(XIDhload(2,1),'pos',pos(6,:)+... [0 0 0 2*buth+2*4],'style','edit',... 'String','','max',2,'Backgroundcolor','w'); uicontrol(XIDhload(2,1),'pos',pos(3,:),'style',... 'text','string','Notes:','Horizontalalignment','left'); uicontrol(XIDhload(2,1),'pos',pos(2,:),... 'style','text','string','Optional Model Information',... 'HorizontalAlignment','center','Fontweight','bold'); % LEVEL 3 Frame for Variable info lev3=pos(1,2)+pos(1,4); pos = iduilay1(FigW,5,5,lev3,3,2); uicontrol(XIDhload(2,1),'pos',pos(1,:),'style','frame'); uicontrol(XIDhload(2,1),'pos',pos(2,:),'style','text','string',... 'Model Variable','Fontweight','bold'); uicontrol(XIDhload(2,1),'pos',pos(4,:)+[0 0 0 buth],'style','text','string',... 'Enter the name of a workspace variable in ''theta format''', ... 'HorizontalAlignment','left') XIDhload(2,4) = uicontrol(XIDhload(2,1),'pos',... pos(5,:),'style','edit',... 'String','','Backgroundcolor','w','callback',... [cb1,'XIDarg=''prep_model'';,iduifscr;',cb3]); FigWH=[FigW pos(1,2)+pos(1,4)+mEdgeToFrame]; ScreenPos = get(0,'ScreenSize'); Sumbpos=get(XIDsumb(1),'pos'); FigXY=max([0,0],(Sumbpos(1:2)+Sumbpos(3:4)-[0,FigWH(2)])); FigXY=min(FigXY,ScreenPos(3:4)-FigWH); FigPos=[FigXY FigWH]; set(XIDhload(2,1),'pos',FigPos); if length(XIDlayout)>16 if XIDlayout(17,3) eval('set(XIDhload(2,1),''pos'',XIDlayout(17,1:4));','') end end if nargin<3, set(XIDhload(2,1),'vis','on'),end set(get(XIDhload(2,1),'children'),'units','norm'); iduistat('Enter model variable name.') end elseif strcmp(arg,'insert') iduistat('Inserting the data set ... '); strload=[]; input=get(XIDhload(1,11),'userdata'); output=get(XIDhload(1,13),'userdata'); inpn=get(XIDhload(1,11),'string'); outn=get(XIDhload(1,13),'string'); dAta_n=get(XIDhload(1,4),'string'); if isempty(dAta_n) dAta_n=[outn,inpn];set(XIDhload(1,4),'string',dAta_n),drawnow end [Nny,ny]=size(output); % felmedd om 0 if Nny==0 iduistat('No data inserted.'); return end [Nnu,nu]=size(input); % felmedd om 0 if Nny~=Nnu&Nnu>0 errordlg('The input and output must have the same number of rows.'); iduistat('No data inserted.'); return end if isempty(inpn) loadcom=[' ',dAta_n,' = [',outn,'];']; else loadcom=[' ',dAta_n,'=[[',outn,'],[ ',inpn,']];']; end strload=str2mat(strload,loadcom); nustr=[];nystr=[]; for kk=1:nu nustr=[nustr,int2str(kk),' ']; end for kk=1:ny nystr=[nystr,int2str(kk),' ']; end str1=get(XIDhload(1,6),'string'); str2=get(XIDhload(1,8),'string'); if iduifile('test1',str1,'tsamp');return,end if iduifile('test1',str2,'startt');return,end dAta_info=str2mat(str1,int2str(ny),str2,... int2str(Nny),int2str(nu),nystr,nustr); SL=get(XIDhload(1,12),'string'); if ~isempty(SL) dAta_info=str2mat(dAta_info,SL); end dAta_info=str2mat(dAta_info,... strload,[' % Import ',dAta_n]); iduiinsd([output input],dAta_info,dAta_n); elseif strcmp(arg,'reset') iduistat('Resetting the dialog entries ...') if file==2 set(XIDhload(2,[4,12]),'string',''); elseif any(file==[1,3]) set(XIDhload(file,[4,12]),'string',''); set(XIDhload(file,8),'string',int2str(1)); set(XIDhload(file,6),'string',int2str(1)); if file==1,set(XIDhload(1,[11,13]),'string','');end if file==3,set(XIDhload(3,10),'string',int2str(1));end end iduistat('') elseif strcmp(arg,'test1') % Test if sampling interval is reasonable if nargin<2 Tsstring=get(iduigco,'string'); tagg=get(iduigco,'tag'); else Tsstring=file; tagg=dum; end outarg=0; eval('testts=eval(Tsstring);','outarg=1;') if strcmp(tagg,'tsamp') msg=str2mat('The sampling interval could not be evaluated.',... 'It must be given as a positive real number.',... 'Variable names in the workspace cannot be used.'); else msg=str2mat('The starting time could not be evaluated.',... 'It must be given as a real number.',... 'Variable names in the workspace cannot be used.'); end if outarg errordlg(msg); return end if length(testts)>1|length(testts)<1,errordlg(msg);return,end if isstr(testts),outarg=1;end if testts(1)<=0&strcmp(tagg,'tsamp'),outarg=1;end if outarg errordlg(msg); return end end