📄 dfield7.m
字号:
'string','=',... 'visible','off'); ud.h.pval(K) = uicontrol('style','edit',... 'pos',[pvleft pbot(jj) pvalw texth],... 'string',value,... 'call',pvcall,... 'visible','off',... 'user',K,... 'backgroundcolor','w'); end end ud.c.pname = pname; ud.c.pval = pval; pbot = pbot + texth; frame(2) = uicontrol('style','frame','pos',disfrwind,'visible','off'); w1 = [ 'ud = get(gcf,''user'');'... 'nnn = str2num(get(ud.h.wind(1),''string''));'... 'if isempty(nnn),',... ' set(ud.h.wind(1),''string'',''?'');',... ' nnn = NaN;',... 'end,',... 'ud.c.wind(1) = nnn;',... 'set(gcf,''user'',ud);']; w2 = [ 'ud = get(gcf,''user'');'... 'nnn = str2num(get(ud.h.wind(2),''string''));'... 'if isempty(nnn),',... ' set(ud.h.wind(2),''string'',''?'');',... ' nnn = NaN;',... 'end,',... 'ud.c.wind(2) = nnn;',... 'set(gcf,''user'',ud);']; w3 = [ 'ud = get(gcf,''user'');'... 'nnn = str2num(get(ud.h.wind(3),''string''));'... 'if isempty(nnn),',... ' set(ud.h.wind(3),''string'',''?'');',... ' nnn = NaN;',... 'end,',... 'ud.c.wind(3) = nnn;',... 'set(gcf,''user'',ud);']; w4 = [ 'ud = get(gcf,''user'');'... 'nnn = str2num(get(ud.h.wind(4),''string''));'... 'if isempty(nnn),',... ' set(ud.h.wind(4),''string'',''?'');',... ' nnn = NaN;',... 'end,',... 'ud.c.wind(4) = nnn;',... 'set(gcf,''user'',ud);']; winbot1 = disfrbot + disfrht - 5 - separation; winbot2 = winbot1 - separation; winbot3 = winbot2 - separation; windw = 40*rr; twindw = (disfrw - 10)/2-windw; twindl = eqleft + twindw + windw; dwind = uicontrol('style','text',... 'pos',[eqleft winbot1 disfrw-10 texth],... 'horizon','center',... 'string','The display window.','visible','off',... 'backgroundcolor',tcolor); % ud.h.twind contains the handles to the text windows, and ud.h.wind % contains the handles to the edit windows. ud.h.twind(1) = uicontrol('style','text',... 'pos',[eqleft winbot2-fudge twindw texth],... 'horizon','right',... 'string',['The minimum value of ',ud.o.tname,' = '],... 'visible','off','backgroundcolor',tcolor); ud.h.wind(1) = uicontrol('style','edit',... 'pos',[eqleft+twindw winbot2 windw texth],... 'string',num2str(ud.o.wind(1)),... 'call',w1,'visible','off',... 'backgroundcolor',ecolor); ud.h.twind(2) = uicontrol('style','text',... 'pos',[eqleft winbot3-fudge twindw texth],... 'horizon','right',... 'string',['The maximum value of ',ud.o.tname,' = '],... 'visible','off','backgroundcolor',tcolor); ud.h.wind(2) = uicontrol('style','edit',... 'pos',[eqleft+twindw winbot3 windw texth],... 'string',num2str(ud.o.wind(2)),... 'call',w2,'visible','off',... 'backgroundcolor',ecolor); ud.h.twind(3)= uicontrol('style','text',... 'pos',[twindl winbot2-fudge twindw texth],... 'horizon','right',... 'string',['The minimum value of ',ud.o.xname,' = '],... 'visible','off','backgroundcolor',tcolor); ud.h.wind(3) = uicontrol('style','edit',... 'pos',[twindl+twindw winbot2 windw texth],... 'string',num2str(ud.o.wind(3)),... 'call',w3,'visible','off',... 'backgroundcolor',ecolor); ud.h.twind(4) = uicontrol('style','text',... 'pos',[twindl winbot3-fudge twindw texth],... 'horizon','right',... 'string',['The maximum value of ',ud.o.xname,' = '],... 'visible','off','backgroundcolor',tcolor); ud.h.wind(4) = uicontrol('style','edit',... 'pos',[twindl+twindw winbot3 windw texth],... 'string',num2str(ud.o.wind(4)),... 'call',w4,'visible','off',... 'backgroundcolor',ecolor); butt(1) = uicontrol('style','push',... 'pos',qwind,... 'string','Quit',... 'call','dfield7(''quit'')',... 'visible','off'); butt(2) = uicontrol('style','push',... 'pos',rwind,... 'string','Revert',... 'call','dfield7(''revert'')',... 'visible','off'); butt(3) = uicontrol('style','push',... 'pos',pwind,... 'string','Proceed',... 'call','dfield7(''proceed'')',... 'visible','off'); hhsetup = get(0,'showhiddenhandles'); set(0,'showhiddenhandles','on'); delgall = ['sud = get(gcf,''user'');',... 'mh = get(sud.h.gallery,''children'');',... 'add = findobj(sud.h.gallery,''tag'',''add system'');',... 'mh(find(mh == add)) = [];',... 'delete(mh);',... 'set(sud.h.gallery,''user'',[]);',... 'set(findobj(''tag'',''load default''),''enable'',''on'')']; mefile = findobj(dfset,'label','&File'); meedit = findobj(gcf,'label','&Edit'); metools = findobj(gcf,'label','&Tools'); meview = findobj(gcf,'label','&View'); meinsert = findobj(gcf,'label','&Insert'); delete([metools,meview,meinsert]); % File menu meexp = findobj(mefile,'label','&Export...'); meprev = findobj(mefile,'label','Print Pre&view...'); mepset = findobj(mefile,'label','Pa&ge Setup...'); set(get(mefile,'child'),'vis','off'); meload = uimenu(mefile,'label','Load an equation ...',... 'call','dfield7(''loadsyst'',''system'');',... 'pos',1); mesave = uimenu(mefile,'label','Save the current equation ...',... 'call','dfield7(''savesyst'',''system'');',... 'pos',2); meloadg = uimenu(mefile,'label','Load a gallery ...',... 'call','dfield7(''loadsyst'',''gallery'');',... 'separator','on','pos',3); mesaveg = uimenu(mefile,'label','Save a gallery ...',... 'call','dfield7(''savesyst'',''gallery'');',... 'tag','savegal','pos',4); medelg = uimenu(mefile,'label','Delete the current gallery',... 'call',delgall,'pos',5); melddg = uimenu(mefile,'label','Load the default gallery',... 'call','dfield7(''loadsyst'',''default'');',... 'enable','on',... 'tag','load default','pos',6); meproceed = uimenu(mefile,'label','Proceed','call',... 'dfield7(''proceed'')','separator','on',... 'accelerator','G','pos',7); merevert = uimenu(mefile,'label','Revert','call',... 'dfield7(''revert'')','separator','off','pos',8); set(mepset,'vis','on','pos',9); set(meprev,'vis','on','label','Page Pre&view...','pos',10); set(meexp,'vis','on','pos',11,'separator','off'); merestart = uimenu(mefile,'label','Restart dfield7','call',... 'dfield7(''restart'')','separator','on','pos',12); mequit = uimenu(mefile,'label','Quit dfield7','call',... 'dfield7(''quit'')','separator','on','pos',13); % Edit menu. set(get(meedit,'child'),'vis','off'); meclrf = uimenu(meedit,'label','Clear equations',... 'call',['ud = get(gcf,''user'');h = ud.h;',... 'set([h.xname,h.der,h.tname,h.der],''string'','''');'],... 'accelerator','E'); pclear = [ 'ud = get(gcf,''user'');h = ud.h;',... 'set([h.pname,h.pval],''string'','''');',... 'ud.c.pname = {};',... 'ud.c.pval = {};',... 'set(gcf,''user'',ud);',... ]; meclrp = uimenu(meedit,'label','Clear parameters',... 'call',pclear,... 'accelerator','N'); meclrwind = uimenu(meedit,'label','Clear display window',... 'call',['ud = get(gcf,''user'');',... 'set(ud.h.wind,''string'','''');'],... 'accelerator','D'); allclear = [ 'ud = get(gcf,''user'');h = ud.h;',... 'set([h.xname,h.der,h.tname],''string'','''');',... 'set([h.pname,h.pval,h.wind],''string'','''');',... 'ud.c.pname = {};',... 'ud.c.pval = {};',... 'set(gcf,''user'',ud);',... ]; meclrall = uimenu(meedit,'label','Clear all',... 'call',allclear,... 'accelerator','A',... 'separator','on'); % Gallery menu. sysmenu = uimenu('label','Gallery','visible','off','pos',3); meadd = uimenu(sysmenu,'label','Add current equation to the gallery',... 'call','dfield7(''addgall'');','tag','add system'); sep = 'on'; for kk = 1:length(system) kkk = num2str(kk); if kk == 2, sep = 'off';end sysmen(kk) = uimenu(sysmenu,'label',system(kk).name,... 'call',['dfield7(''system'',',kkk,')'],... 'separator',sep,'visible','on'); end set(sysmenu,'user',system); ud.h.gallery = sysmenu; set(0,'showhiddenhandles',hhsetup); ud.flag = 0; % Record the handles in the User Data of the Set Up figure. set(dfset,'user',ud); hhhh = findobj(dfset,'type','uicontrol'); set(hhhh,'units','normal') set(dfset,'visible','on','resize','on'); set(get(dfset,'children'),'visible','on'); elseif strcmp(action,'revert') ud = get(gcf,'user'); ud.c = ud.o; syst = ud.o; xname = syst.xname; tname = syst.tname; set(ud.h.xname,'string',xname); set(ud.h.tname,'string',tname); set(ud.h.der,'string',syst.der); set(ud.h.twind(1),'string',['The minimum value of ',tname,' = ']); set(ud.h.twind(2),'string',['The maximum value of ',tname,' = ']); set(ud.h.twind(3),'string',['The minimum value of ',xname,' = ']); set(ud.h.twind(4),'string',['The maximum value of ',xname,' = ']); for kk = 1:4 set(ud.h.wind(kk),'string',num2str(syst.wind(kk))); end for kk = 1:4 if kk <= length(syst.pname) name = syst.pname{kk}; else name = ''; end if kk <= length(syst.pval) value = syst.pval{kk}; else value = ''; end set(ud.h.pname(kk),'string',name); set(ud.h.pval(kk),'string',value); end set(gcf,'user',ud); elseif strcmp(action,'proceed') % Proceed connects Setup with the Display window. dfset = gcf; sud = get(dfset,'user'); sud.o = sud.c; set(dfset,'user',sud); % Some error checking that has to be done no matter what. WINvect = sud.c.wind; if any(isnan(WINvect)) errmsg = ['One of the entries defining the display window ',... 'is not a number.']; fprintf('\a') errordlg(errmsg,'dfield7 error','on'); return end xstr = sud.c.xname; if isempty(xstr) errmsg = 'The dependent variable needs a name.'; fprintf('\a') errordlg(errmsg,'dfield7 error','on'); return end tstr = sud.c.tname; if isempty(tstr) errmsg = 'The independent variable needs a name.'; fprintf('\a') errordlg(errmsg,'dfield7 error','on'); return end if WINvect(2)<= WINvect(1) errmsg = ['The minimum value of ', tstr,... ' must be smaller than the maximum value.']; fprintf('\a') errordlg(errmsg,'dfield7 error','on'); return end if WINvect(4)<= WINvect(3) errmsg = ['The minimum value of ', xstr,... ' must be smaller than the maximum value.']; fprintf('\a') errordlg(errmsg,'dfield7 error','on'); return end % sud.flag = 0 if this is the first time through for this equation, % sud.flag = 1 if only the window dimensions have been changed. % If sud.flag == 1 we only have to update things. if (sud.flag == 1) dfdisp = findobj('name','dfield7 Display'); dud = get(dfdisp,'user'); aud = get(dud.axes,'user'); tstr = get(get(dud.axes,'title'),'string'); wind = sud.c.wind(:); hmax = dud.settings.hmax; if (~all(wind == dud.syst.wind(:))) dwind = [wind(1); wind(3); -wind(2); -wind(4)]; DY = [wind(2)-wind(1); wind(4)-wind(3)]; hmax = min(hmax,DY(1)/4); aud.DY = DY; aud.cwind = wind - dud.settings.magn*[DY(1);-DY(1);DY(2);-DY(2)]; set(dud.axes,'user',aud); end dud.syst = sud.c; dud.settings = sud.settings; dud.settings.hmax = hmax; set(dfdisp,'user',dud); dfield7('dirfield',dfdisp); else sud.flag = 1; set(dfset,'user',sud); Arrflag = sud.fieldtype; NumbFPts = sud.npts; Xname = sud.c.xname; Tname = sud.c.tname; derivstr = sud.c.der; pname = sud.c.pname; parav = get(sud.h.pval,'string'); % First remove the blanks. derivstr(find(abs(derivstr)==32))=[]; for kk = 1:4 paraval = parav{kk}; if ~isempty(paraval) paraval(find(abs(paraval)==32))=[]; parav{kk} = paraval; end end % Next remove the periods inserted by users attempting to make the % function array smart. l=length(derivstr); for ( k = fliplr(findstr('.',derivstr))) if (find('*/^' == derivstr(k+1))) derivstr = [derivstr(1:k-1), derivstr(k+1:l)]; end l=l-1; end for kk = 1:4 paraval = parav{kk}; l=length(paraval); for ( k = fliplr(findstr('.',paraval))) if (find('*/^' == paraval(k+1))) paraval = [paraval(1:k-1), paraval(k+1:l)]; end l=l-1; end parav{kk} = paraval; end % Build strings for the title. txderstr = derivstr; kxder = find(abs(txderstr)==42); % Get rid of *s txderstr(kxder)=' '*ones(size(kxder)); txderstr = strrep(txderstr,'-',' - '); % Extra spaces txderstr = strrep(txderstr,'+',' + '); if (abs(txderstr(1)) == 32) % Get rid of starting space txderstr = txderstr(2:length(txderstr)); end tstr = [Xname,' '' = ', txderstr]; pstring = cell(4,1); pstring{1} = ''; pstring{2} = ''; pstring{3} = ''; pstring{4} = ''; for kk = 1:4 if ~isempty(parav{kk}); tp1str = parav{kk}; kxder = find(abs(tp1str)==42); % Get rid of *s tp1str(kxder)=' '*ones(size(kxder)); tp1str = strrep(tp1str,'-',' - '); % Extra spaces tp1str = strrep(tp1str,'+',' + '); if (abs(tp1str(1)) == 32) % Get rid of starting space tp1str = tp1str(2:length(tp1str));
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -