📄 pplane7.m
字号:
disfrwind = [left, disfrbot, disfrw, disfrht];
pfrbot = disfrbot + disfrht +frsep; % Parameter frame.
pfrw = dfigwidth -2*left;
pfrht = 3*separation + 10;
pfrwind = [left, pfrbot, pfrw, pfrht];
defrbot = pfrbot + pfrht + frsep; % Equation frame.
defrw = pfrw;
defrht = 3*separation + 10;
defrwind = [left, defrbot, defrw, defrht];
ffrbot = disfrbot; % Field frame.
ffrleft = left + disfrw + frsep;
ffrw = dfigwidth -left - ffrleft;
ffrht = disfrht;
ffrwind = [ffrleft, ffrbot, ffrw, ffrht];
dfigureheight = defrbot + defrht +frsep; % Height of the figure.
set(ppset,'pos',[30 dfigurebot dfigwidth dfigureheight]);
set(frame(1),'pos',defrwind);
xname=[
'ud = get(gcf,''user'');'...
'Xname=get(ud.h.xvar,''string'');'...
'minxstr = [''The minimum value of '',Xname,'' = ''];',...
'set(ud.h.twind(1),''string'',minxstr);'...
'maxxstr = [''The maximum value of '',Xname,'' = ''];',...
'set(ud.h.twind(2),''string'',maxxstr);'...
'ud.c.xvar = Xname;'...
'ud.flag = 0;'...
'ud.c.name = '''';',...
'set(gcf,''user'',ud);'];
yname=[
'ud = get(gcf,''user'');'...
'Yname=get(ud.h.yvar,''string'');'...
'minystr = [''The minimum value of '',Yname,'' = ''];',...
'set(ud.h.twind(3),''string'',minystr);'...
'maxystr = [''The maximum value of '',Yname,'' = ''];',...
'set(ud.h.twind(4),''string'',maxystr);'...
'ud.c.yvar = Yname;'...
'ud.flag = 0;'...
'ud.c.name = '''';',...
'set(gcf,''user'',ud);'];
xder =[
'ud = get(gcf,''user'');'...
'ud.c.xder = get(ud.h.xder,''string'');'...
'ud.flag = 0;'...
'ud.c.name = '''';',...
'set(gcf,''user'',ud);'];
yder =[
'ud = get(gcf,''user'');'...
'ud.c.yder = get(ud.h.yder,''string'');'...
'ud.flag = 0;'...
'ud.c.name = '''';',...
'set(gcf,''user'',ud);'];
equationbot = defrbot + 5;
eqlabelbot = equationbot + 2*separation;
xbot = equationbot + separation; % Bottom of x equation.
ybot = equationbot; % Bottom of y equation.
lablen =200*rr;
eqlableft = (dfigwidth-lablen)/2;
eqleft = left + 5;
fudge = 0.15*separation;
set(eq(1),'pos',[eqlableft eqlabelbot lablen texth]);
tcolor = get(gcf,'defaultuicontrolbackgroundcolor');
ecolor = 'w';
ud.h.xvar=uicontrol('pos',[eqleft, xbot, varw, texth],...
'style','edit',...
'horizon','right',...
'string',ud.o.xvar,...
'call',xname,...
'backgroundcolor',ecolor,...
'visible','off');
eq(2) = uicontrol('style','text',...
'pos',[eqleft+varw xbot equalw texth],...
'horizon','center',...
'string',''' = ',...
'backgroundcolor',tcolor,...
'visible','off');
ud.h.xder=uicontrol('pos',[eqleft+varw+equalw xbot eqlength texth],...
'string',ud.o.xder,...
'horizon','left','style','edit',...
'backgroundcolor',ecolor,...
'call',xder,'visible','off');
ud.h.yvar=uicontrol('pos',[eqleft ybot varw texth],...
'style','edit',...
'horizon','right',...
'string',ud.o.yvar,...
'backgroundcolor',ecolor,...
'call',yname,'visible','off');
eq(3) = uicontrol('style','text',...
'pos',[eqleft+varw ybot equalw texth],...
'horizon','center','string',''' = ',...
'backgroundcolor',tcolor',...
'visible','off');
ud.h.yder=uicontrol('pos',[eqleft+varw + equalw ybot eqlength texth],...
'string',ud.o.yder,...
'horizon','left','style','edit',...
'backgroundcolor',ecolor,...
'call',yder,'visible','off');
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;',...
'ud.c.name = '''';',...
'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;',...
'ud.c.name = '''';',...
'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;',...
'ud.c.name = '''';',...
'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;',...
'ud.c.name = '''';',...
'set(gcf,''user'',ud);'];
winbot1 = disfrbot + disfrht - 5 - separation;
winbot2 = winbot1 - separation;
winbot3 = winbot2 - separation;
winbot4 = winbot3 - separation;
winbot5 = winbot4 - separation;
dwindow = uicontrol('style','text',...
'pos',[eqleft winbot1 disfrw-10 texth],...
'horizon','center',...
'string','The display window.','visible','off');
% ud.h.twind contains the handles to the text windows, and ud.h.wind
% contains the handles to the edit windows.
twstr1 = ['The minimum value of ',ud.o.xvar,' = '];
ud.h.twind(1) = uicontrol('style','text',...
'pos',[eqleft winbot2 winstrlen texth],...
'horizon','right',...
'string',twstr1,...
'backgroundcolor',tcolor',...
'visible','off');
ud.h.wind(1) = uicontrol('style','edit',...
'pos',[eqleft+winstrlen winbot2 40*rr texth],...
'string',num2str(ud.o.wind(1)),...
'backgroundcolor',ecolor,...
'call',w1,'visible','off');
twstr2 = ['The maximum value of ',ud.o.xvar,' = '];
ud.h.twind(2) = uicontrol('style','text',...
'pos',[eqleft winbot3 winstrlen texth],...
'horizon','right',...
'string',twstr2,...
'backgroundcolor',tcolor',...
'visible','off');
ud.h.wind(2) = uicontrol('style','edit',...
'pos',[eqleft+winstrlen winbot3 40*rr texth],...
'string',num2str(ud.o.wind(2)),...
'backgroundcolor',ecolor,...
'call',w2,'visible','off');
twstr3 = ['The minimum value of ',ud.o.yvar,' = '];
ud.h.twind(3)= uicontrol('style','text',...
'pos',[eqleft winbot4 winstrlen texth],...
'horizon','right',...
'string',twstr3,...
'backgroundcolor',tcolor',...
'visible','off');
ud.h.wind(3) = uicontrol('style','edit',...
'pos',[eqleft+winstrlen winbot4 40*rr texth],...
'string',num2str(ud.o.wind(3)),...
'backgroundcolor',ecolor,...
'call',w3,'visible','off');
twstr4 = ['The maximum value of ',ud.o.yvar,' = '];
ud.h.twind(4) = uicontrol('style','text',...
'pos',[eqleft winbot5 winstrlen texth],...
'horizon','right',...
'string',twstr4,...
'backgroundcolor',tcolor',...
'visible','off');
ud.h.wind(4) = uicontrol('style','edit',...
'pos',[eqleft+winstrlen winbot5 40*rr texth],...
'string',num2str(ud.o.wind(4)),...
'backgroundcolor',ecolor,...
'call',w4,'visible','off');
frame(3)=uicontrol('style','frame','pos',pfrwind,'visible','off');
pncall = [
'[h,fig] = gcbo;'...
'ud = get(fig,''user'');'...
'num = get(h,''user'');'...
'ud.c.pname{num} = get(ud.h.pname(num),''string'');'...
'ud.flag = 0;'...
'set(gcf,''user'',ud);'];
pvcall = [
'[h,fig] = gcbo;'...
'ud = get(fig,''user'');'...
'num = get(h,''user'');'...
'ud.c.pval{num} = get(ud.h.pval(num),''string'');'...
'ud.flag = 0;'...
'set(gcf,''user'',ud);'];
pnamew = 40*rr;
pvalw = 50*rr;
peqw = 10*rr;
pbot(3) = pfrbot + 5;
pbot(2) = pbot(3) + separation;
pbot(1) = pbot(2) + separation;
pleft1 = eqleft + 50*rr + 5;
peqleft1 = pleft1 + pnamew;
pvleft1 = peqleft1 + peqw;
pleft2 = dfigwidth - 10 - pnamew - pvalw - peqw;
peqleft2 = pleft2 + pnamew;
pvleft2 = peqleft2 + peqw;
paratit=uicontrol('style','text',...
'horizon','center',...
'string',{'Parameters';'or';'expressions'},...
'backgroundcolor',tcolor',...
'visible','off');
ext = get(paratit,'extent');
paratitw = ext(3);
pos = [eqleft pfrbot+2+texth/2 paratitw 2.1*texth];
set(paratit,'pos',pos);
psep = 20;
pvalw = (dfigwidth - 2*eqleft - paratitw)/2 - psep - pnamew - peqw;
pval = ud.c.pval;
pname = ud.c.pname;
for jj = 1:3
for kk = 1:2
pleft = eqleft + paratitw +psep +(kk-1)*(pnamew+peqw+pvalw+ psep);
peqleft = pleft + pnamew;
pvleft = peqleft + peqw;
K = kk +2*(jj-1);
name = pname{K};
value = pval{K};
ud.h.pname(K) = uicontrol('style','edit',...
'pos',[pleft pbot(jj) pnamew texth],...
'horizon','right','string',name,...
'user',K,...
'call',pncall,...
'visible','off',...
'backgroundcolor','w');
equal(K) = uicontrol('style','text',...
'pos',[peqleft pbot(jj)-fudge peqw texth],...
'horizon','center',...
'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;
butt(1) = uicontrol('style','push',...
'pos',qwind,...
'string','Quit','call',...
'pplane7(''quit'')',...
'visible','off');
butt(2) = uicontrol('style','push',...
'pos',rwind,...
'string','Revert',...
'call','pplane7(''revert'')',...
'visible','off');
butt(3) = uicontrol('style','push',...
'pos',pwind,...
'string','Proceed',...
'call','pplane7(''proceed'')',...
'visible','off');
fframe = uicontrol('style','frame','pos',ffrwind,'visible','off');
ffrtitle = uicontrol('style','text',...
'pos',[ffrleft+5,winbot1,ffrw-10,texth],...
'string','The direction field.',...
'horizon','center','visible','off');
radleft = ffrleft + 3;
radw = 50*rr;
typewindw = radw +6;
typewind = [ffrleft, ffrbot, typewindw, ffrht-separation-3];
textwindl = ffrleft+typewindw;
textleft = textwindl + 3;
textw = ffrw - typewindw;
textwind = [textwindl, ffrbot,textw, ffrht-separation-3];
typeframe = uicontrol('style','frame','pos',typewind,'visible','off');
textframe = uicontrol('style','frame','pos',textwind,'visible','off');
switch ud.o.fieldtype
case 'nullclines'
rval1 = 1;rval2 = 0;rval3 = 0;rval4 = 0;
case 'lines'
rval1 = 0;rval2 = 2;rval3 = 0;rval4 = 0;
case 'arrows'
rval1 = 0;rval2 = 0;rval3 = 3;rval4 = 0;
case 'none'
rval1 = 0;rval2 = 0;rval3 = 0;rval4 = 4;
otherwise
error(['Unknown fieldtype ',ud.o.fieldtype,'.'])
end
ud.h.rad(1) = uicontrol('style','radio',...
'pos',[radleft winbot4 radw texth],...
'string','Nullclines',...
'value',rval1,...
'visible','off');
ud.h.rad(2) = uicontrol('style','radio',...
'pos',[radleft winbot3 radw texth],...
'string','Lines',...
'value',rval2,...
'max',2,...
'visible','off');
ud.h.rad(3) = uicontrol('style','radio',...
'pos',[radleft winbot2 radw texth],...
'string','Arrows',...
'value',rval3,...
'max',3,...
'visible','off');
ud.h.rad(4) = uicontrol('style','radio',...
'pos',[radleft winbot5 radw texth],...
'string','None',...
'value',rval4,...
'max',4,...
'visible','off');
for i=1:4
set(ud.h.rad(i),'user',ud.h.rad(:,[1:(i-1),(i+1):4]));
end
callrad = [
'me = get(gcf,''currentobject'');',...
'kk = get(me,''max'');',...
'set(get(me,''user''),''value'',0),',...
'set(me,''value'',kk);',...
'ud = get(gcf,''user'');',...
'switch kk,',...
' case 1, ud.c.fieldtype = ''nullclines'';',...
' case 2, ud.c.fieldtype = ''lines'';',...
' case 3, ud.c.fieldtype = ''arrows'';',...
' case 4, ud.c.fieldtype = ''none'';',...
'end,',...
'set(gcf,''user'',ud);'];
set(ud.h.rad,'call',callrad);
nfptsstr = {'Number of'; 'field points per'; 'row or column.'};
nfptstext = uicontrol('style','text',...
'pos',[textleft winbot4 textw-5 2.5*texth],...
'string',nfptsstr,...
'horizon','center',...
'visible','off');
callnfpts = [
'ppset = findobj(''name'',''pplane7 Setup'');',...
'ud = get(ppset,''user'');'...
'me = ud.h.npts;',...
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -