📄 pplane7.m
字号:
delete(waith);
return
end %if false
switch date
case 'old'
x = 19/(kk+38);
xp = [xp(2),x,x,xp(2)];
set(patchh,'xdata',xp);
set(lineh,'xdata',xl);
drawnow;
nnn = kk/19;
flds = fieldnames(sud.c);
flds=flds(:);
for j = 0:(nnn-1)
newsystemp = newsysts([(j*19+1):(j+1)*19]);
newsyst.name = newsystemp{1};
newsyst.xvar = newsystemp{2};
newsyst.yvar = newsystemp{3};
newsyst.xder = newsystemp{4};
newsyst.yder = newsystemp{5};
newsyst.pname = {newsystemp{6}, newsystemp{7},...
newsystemp{8}, newsystemp{9},'',''};
newsyst.pval = {newsystemp{10},...
newsystemp{11},...
newsystemp{12},...
newsystemp{13},'',''};
newsyst.fieldtype = newsystemp{14};
newsyst.npts = str2num(newsystemp{15});
wind = newsystemp(16:19);
newsyst.wind = [str2num(wind{1}),str2num(wind{2}),...
str2num(wind{3}),str2num(wind{4})];
newsysstruct(j+1) = newsyst;
end % for j = 0:(nnn-1)
case 'new'
x = 11/(kk+22);
xp = [xp(2),x,x,xp(2)];
set(patchh,'xdata',xp);
set(lineh,'xdata',xl);
drawnow;
nnn = kk/11;
for j = 1:nnn
for k = 2:11;
eval(newsysts{(j-1)*11+k});
end
newsysstruct(j) = H;
end
end %switch date
end % if strcmp(type,'default') & else
nnn = length(newsysstruct);
ignoresyst = {};
for j = 1:nnn
x = (j+1)/(nnn+2);
xp = [xp(2),x,x,xp(2)];
set(patchh,'xdata',xp);
set(lineh,'xdata',xl);
drawnow;
newsyst = newsysstruct(j);
sname = newsyst.name;
sname(find(abs(sname) == 95)) = ' '; % Replace underscores with spaces.
newsyst.name = sname;
ignore = pplane7('addgall',newsyst);
if ignore == -1;
ignoresyst{length(ignoresyst)+1} = sname;
end
end % for j = 1:nnn
l = length(ignoresyst);
if l % There was at least one system which was a dup with a
% different name.
if l == 1
message = {['The system ',ignoresyst{1},'" duplicates a ',...
'system already in the gallery and was not added.']};
else
message = 'The systems ';
for k = 1:(l-1)
message = [message,'"',ignoresyst{k},'", '];
end
message = {[message,'and "',ignoresyst{l},'" duplicate ',...
'systems already in the gallery and were not added.']};
end % if l == 1 & else
helpdlg(message,'Ignored systems');
end % if l
if strcmp(type,'system') % Added a system.
if ignore > 0 % The system was ignored.
kk = ignore;
else
systems = get(sud.h.gallery,'user');
kk = length(systems);
end
pplane7('system',kk);
end
if strcmp('type','default')
pplane7('system',1);
end
set(sud.h.gallery,'enable','on');
x = 1;
xp = [xp(2),x,x,xp(2)];
set(patchh,'xdata',xp);
set(lineh,'xdata',xl);
drawnow;
delete(waith);
elseif strcmp(action,'addgall')
output = 0;
ppset = findobj('name','pplane7 Setup');
sud = get(ppset,'user');
if nargin < 2 % We are adding the current system.
syst = sud.c;
snstr = 'Provide a name for this system.';
sname = inputdlg(snstr,'System name',1,{syst.name});
if isempty(sname),return;end
sname = sname{1};
if ~strcmp(sname,syst.name)
sud.c.name = sname;
set(ppset,'user',sud);
syst.name = sname;
end
else % We have a system coming from a file.
syst = input1;
sname = syst.name;
end
pnl = length(syst.pname);
for kk = (pnl+1):6
syst.pname{kk} = '';
end
pvl = length(syst.pval);
for kk = (pvl+1):6
syst.pval{kk} = '';
end
systems = get(sud.h.gallery,'user');
ll = length(systems);
kk = 1;
while ((kk<=ll) & (~strcmp(sname,systems(kk).name)))
kk = kk + 1;
end
nameflag = (kk<=ll);
ssyst = rmfield(syst,'name');
kk = 1;
while ((kk<=ll) & (~isequal(ssyst,rmfield(systems(kk),'name'))))
kk = kk + 1;
end
systflag = 2*(kk<=ll);
flag = nameflag + systflag;
switch flag
case 1 % Same name but different system.
mh = findobj(sud.h.gallery,'label',sname);
prompt = {['The system "',sname,'", which you wish to ',...
'add to the gallery has ',...
'the same name as a different system ',...
'already in the gallery. Please ',...
'specify the name for the newly added system.'],...
'Specify the name for the old system.'};
title = 'Two systems with the same name';
lineno = 1;
defans = {sname,sname};
answer = inputdlg(prompt,title,lineno,defans);
if isempty(answer),return,end
sname = answer{1};
systems(kk).name = answer{2};
set(mh,'label',answer{2});
output = kk;
case 2 % Two names for the same system.
oldname = systems(kk).name;
mh = findobj(sud.h.gallery,'label',oldname);
prompt = {['The system "',sname,'", which you wish to add ',...
'to the gallery is the same as a system which is ',...
'already in the gallery with the name "',oldname,'". ',...
'Please specify which name you wish to use.']};
title = 'Two names for the same system.';
lineno = 1;
defans = {oldname};
answer = inputdlg(prompt,title,lineno,defans);
if isempty(answer),return,end
systems(kk).name = answer{1};
set(mh,'label',answer{1});
output = kk;
case 3 % Systems and names the same.
output = -1;
otherwise
end % switch
set(sud.h.gallery,'user',systems);
syst.name = sname;
if flag <=1
switch ll
case 0
systems = syst;
sepstr = 'on';
case 10
systems(11) = syst;
if strcmp(systems(10).name,'square limit set')
sepstr = 'on';
else
sepstr = 'off';
end
otherwise
systems(ll+1) = syst;
sepstr = 'off';
end
kkk = num2str(ll+1);
newmenu = uimenu(sud.h.gallery,'label',sname,...
'call',['pplane7(''system'',',kkk,')'],...
'separator',sepstr);
set(findobj('tag','savegal'),'enable','on');
end
set(sud.h.gallery,'user',systems);
elseif strcmp(action,'system')
ppset = findobj('name','pplane7 Setup');
ud = get(ppset,'user');
kk = input1;
if isstr(kk)
kk = str2num(input1);
end
system = get(ud.h.gallery,'user');
syst = system(kk);
xname = syst.xvar;
yname = syst.yvar;
set(ud.h.xvar,'string',xname);
set(ud.h.yvar,'string',yname);
set(ud.h.xder,'string',syst.xder);
set(ud.h.yder,'string',syst.yder);
pname = syst.pname;
pval = syst.pval;
pnl = length(pname);
pvl = length(pval);
for kk = 1:6
if kk <= pnl
set(ud.h.pname(kk),'string',pname{kk});
else
set(ud.h.pname(kk),'string','');
syst.pname{kk} = '';
end
if kk <= pvl
set(ud.h.pval(kk),'string',pval{kk});
else
set(ud.h.pval(kk),'string','');
syst.pval{kk} = '';
end
end
ud.o = syst;
ud.c = syst;
set(ud.h.twind(1),'string',['The minimum value of ',xname,' = ']);
set(ud.h.twind(2),'string',['The maximum value of ',xname,' = ']);
set(ud.h.twind(3),'string',['The minimum value of ',yname,' = ']);
set(ud.h.twind(4),'string',['The maximum value of ',yname,' = ']);
for kk = 1:4
set(ud.h.wind(kk),'string',num2str(syst.wind(kk)));
end
set(ud.h.npts,'string',num2str(syst.npts));
switch syst.fieldtype
case 'nullclines'
rval = [1 0 0 0];
case 'lines'
rval = [0 2 0 0];
case 'arrows'
rval = [0 0 3 0];
case 'none'
rval = [0 0 0 4];
otherwise
error(['Unknown fieldtype ',ud.o.fieldtype,'.'])
end
for i=1:4
set(ud.h.rad(i),'value',rval(i));
end
ud.flag = 0;
set(ppset,'user',ud);
elseif strcmp(action,'revert')
ud = get(gcf,'user');
ud.c = ud.o;
syst = ud.o;
xname = syst.xvar;
yname = syst.yvar;
set(ud.h.xvar,'string',xname);
set(ud.h.yvar,'string',yname);
set(ud.h.xder,'string',syst.xder);
set(ud.h.yder,'string',syst.yder);
pname = syst.pname;
pval = syst.pval;
pnl = length(pname);
pvl = length(pval);
for kk = 1:6
if kk <= pnl
nstr = pname(kk);
else
nstr = '';
end
if kk <= pvl
vstr = pval(kk);
else
vstr = '';
end
set(ud.h.pname(kk),'string',nstr);
set(ud.h.pval(kk),'string',vstr);
end
set(ud.h.twind(1),'string',['The minimum value of ',xname,' = ']);
set(ud.h.twind(2),'string',['The maximum value of ',xname,' = ']);
set(ud.h.twind(3),'string',['The minimum value of ',yname,' = ']);
set(ud.h.twind(4),'string',['The maximum value of ',yname,' = ']);
for kk = 1:4
set(ud.h.wind(kk),'string',num2str(syst.wind(kk)));
end
set(ud.h.npts,'string',num2str(syst.npts));
switch syst.fieldtype
case 'lines'
rval(1) = 1;
rval(2) = 0;rval(3) = 0;
case 'arrows'
rval(1) = 0;rval(2) = 2;rval(3) = 0;
case 'none'
rval(1) = 0;rval(2) = 0;rval(3) = 3;
otherwise
error(['Unknown fieldtype ',ud.o.fieldtype,'.'])
end
for i=1:3
set(ud.h.rad(i),'value',rval(i));
end
set(gcf,'user',ud);
elseif strcmp(action,'proceed')
% Proceed connects Setup with the Display window.
ppset = gcf;
sud = get(ppset,'user');
sud.o = sud.c;
set(ppset,'user',sud);
he = findobj('name','pplane7 Equilibrium point data');
hl = findobj('name','pplane7 Linearization');
close([he;hl]);
% set([he;hl],'vis','off');
% Some error checking that has to be done no matter what.
WINvect = sud.c.wind;
if any(isnan(WINvect))
sud.flag = 0;
set(ppset,'user',sud);
errmsg = ['One of the entries defining the display window ',...
'is not a number.'];
fprintf('\a')
errordlg(errmsg,'PPLANE error','on');
return
end
xstr = sud.c.xvar;
if isempty(xstr)
sud.flag = 0;
set(ppset,'user',sud);
errmsg = 'The first dependent variable needs a name.';
fprintf('\a')
errordlg(errmsg,'PPLANE error','on');
return
end
ystr = sud.c.yvar;
if isempty(ystr)
sud.flag = 0;
set(ppset,'user',sud);
errmsg = 'The second dependent variable needs a name.';
fprintf('\a')
errordlg(errmsg,'PPLANE error','on');
return
end
if WINvect(2)<= WINvect(1)
sud.flag = 0;
set(ppset,'user',sud);
errmsg = ['The minimum value of ', xstr,...
' must be smaller than the maximum value.'];
fprintf('\a')
errordlg(errmsg,'PPLANE error','on');
return
end
if WINvect(4)<= WINvect(3)
sud.flag = 0;
set(ppset,'user',sud);
errmsg = ['The minimum value of ', ystr,...
' must be smaller than the maximum value.'];
fprintf('\a')
errordlg(errmsg,'PPLANE error','on');
return
end
if isnan(sud.c.npts)
sud.flag = 0;
set(ppset,'user',sud);
errmsg = 'The entry for the number of field points is not a number.';
fprintf('\a')
errordlg(errmsg,'PPLANE 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 or the field data
% have been changed.
% If sud.flag == 1 we only have to update things.
if (sud.flag == 1)
Arrflag = sud.c.fieldtype;
NumbFPts = sud.c.npts;
ppdisp = findobj('name','pplane7 Display');
dud = get(ppdisp,'user');
aud = get(dud.axes,'user');
wind = sud.c.wind(:);
if (~all(wind == dud.syst.wind(:)))
dwind = [wind(1); wind(3); -wind(2); -wind(4)];
aud.DY = [wind(2)-wind(1); wind(4)-wind(3)];
aud.cwind = dwind - dud.settings.magn*[aud.DY;aud.DY];
set(dud.axes,'user',aud);
end
arr = dud.arr;
menull = findobj('tag','null');
switch Arrflag
case 'nullclines'
set([arr.hx;arr.hy;arr.barrows],'vis','on');
set([arr.lines;arr.arrows],'vis','off');
set(menull,'enable','on','label','Hide nullclines.');
case 'lines'
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -