📄 bifurcation.m
字号:
xmax=k_var+0.1;
xmax=min(xmax,vParamRg(2));
elseif min(xutil) < ylim(1)
ymin=min(xutil)-0.1;
elseif ylim(2) < max(xutil)
ymax=max(xutil)+0.1;
end
axis([xmin xmax ymin ymax])
set(hpts,'XData',ud.xpts,'YData',ud.ypts)
else
%plot only the new data.
set(hpts,'XData',k_var*ones(length(xutil),1),'YData',xutil);
end
set(findobj(hndf,'Tag','txtVal'),'String',num2str(k_var))
drawnow
end
%check stop button
ud=get(gcf,'UserData');
if ud.stop, break; end
end
%set buttons
set(findobj(hndf,'Tag','btnStop'), 'Enable', 'off');
set(findobj(hndf,'Tag','btnNewPlot'), 'Enable', 'on');
set(findobj(hndf,'Tag','btnExit'), 'Enable', 'on');
set(findobj(hndf,'Tag','btnBrowse'), 'Enable', 'on');
elseif strcmp(action,'Stop')
hndf=gcf;
%set buttons
set(findobj(hndf,'Tag','btnStop'), 'Enable', 'off');
set(findobj(hndf,'Tag','btnNewPlot'), 'Enable', 'on');
set(findobj(hndf,'Tag','btnExit'), 'Enable', 'on');
set(findobj(hndf,'Tag','btnBrowse'), 'Enable', 'on');
%set flag
ud=get(hndf,'UserData');
ud.stop=1;
set(hndf,'UserData',ud);
elseif strcmp(action,'NewPlot')
hndf=gcf;
ud=get(hndf,'UserData');
fcname=get(findobj(hndf,'Tag','edtTitle'),'String');
h0 = figure('Units','normalized','Color',[1 1 1],'Name','Bifurcation - new plot', ...
'ToolBar','none','Numbertitle','off','Position',[0.15 0.15 0.65 0.7]);
axes('Parent',h0,'Position',[0.07 0.07 0.87 0.85]);
box
plot(ud.xpts,ud.ypts,'.','MarkerSize',1)
axis tight
%Text : axes title
uicontrol('Parent',h0,'Units','normalized','BackgroundColor',[1 1 1], ...
'ForegroundColor',[0 0 0],'Position',[0.255 0.925 0.5 0.05],'Style','text', ...
'String',fcname,'FontSize',15);
elseif strcmp(action,'Browse')
nVal=get(findobj(gcf,'Tag','popupGT'),'Value');%get generator type {Cont, Discr}
d=dir('Discr');
str = {d.name};
[Selection,ok] = listdlg('PromptString','Select a file:',...
'SelectionMode','single',...
'ListString',str(3:end));
if ok
s=cell2struct(str(2+Selection),{'str'},1);
fcname=s.str(1:end-2);
hndf=gcf;
set(findobj(hndf,'Tag','edtTitle'),'FontSize',10,'String',fcname)
%set default values
structData=BifInit(fcname);
vParamRg=structData.ParamRg;
nNbPts=structData.NbPts;
vTimeRange=structData.TimeRange;
nSelVar=structData.SelVar;
y0=structData.InitCond;
if ~isempty(vParamRg) | ~isempty(nNbPts) | ~isempty(vTimeRange) | ~isempty(nSelVar) | ~isempty(y0)
%display default values
plot(0.5,0.5)
cla
set(findobj(hndf,'Tag','edtParamRg'),'String',num2str(vParamRg,4));
set(findobj(hndf,'Tag','edtNbPts'),'String',num2str(nNbPts));
set(findobj(hndf,'Tag','edtTimeRange'),'String',num2str(vTimeRange,4));
set(findobj(hndf,'Tag','edtSelVar'),'String',num2str(nSelVar,2));
set(findobj(hndf,'Tag','edtInitCond'),'String',num2str(y0,3));
set(findobj(hndf,'Tag','txtVal'),'String',[])
end
set(findobj(hndf,'Tag','btnStart'), 'Enable', 'on')
set(findobj(hndf,'Tag','btnStop'), 'Enable', 'off')
set(findobj(hndf,'Tag','btnNewPlot'), 'Enable', 'off')
set(findobj(hndf,'Tag','btnExit'), 'Enable', 'on')
end
elseif strcmp(action,'Exit')
%clear global variables
clear global
%clear paths
rmpath([pwd '\Discr']);
rmpath([pwd '\Prvt']);
%close figure
close(gcf)
end
%---------------- subroutine -----------------
function srtBifurcationGUI
%creates a GUI for bifurcation drawing
%Callback strings
cbstrStart='bifurcation(''Start'')';
cbstrStop='bifurcation(''Stop'')';
cbstrNewPlot='bifurcation(''NewPlot'')';
cbstrHelp='helpwin(''bifurcation'','''',''Bifurcation Help Window'')';
cbstrBrowse='bifurcation(''Browse'')';
cbstrExit='bifurcation(''Exit'')';
WinWidth=0.8; %Window width
WinHeight=0.78; %Window height
BtnWidth=0.12; %Button width
BtnHeight=0.05; %Button height
xPos=0.865; %X-position of buttons
h0 = figure('Units','normalized','Color',[1 1 1],'Name','Bifurcation','NumberTitle','off', ...
'Position',[0.1 0.1 WinWidth WinHeight],'MenuBar','none','ToolBar','none', ...
'Resize','off','Visible','off');
%Frame : left
uicontrol('Parent',h0,'Units','normalized','BackgroundColor',[0.513725 0.6 0.694118], ...
'Position',[0.85 0 0.15 1],'Style','frame');
%Frame : bottom
uicontrol('Parent',h0,'Units','normalized','BackgroundColor',[0.513725 0.6 0.694118], ...
'Position',[0 0 0.85 0.0676],'Style','frame');
%Button : start
uicontrol('Parent',h0,'Units','normalized','Position',[xPos 0.94 BtnWidth BtnHeight], ...
'String','Start','Tag','btnStart','Callback',cbstrStart, 'Enable', 'on');
%Button : stop
uicontrol('Parent',h0,'Units','normalized','Position',[xPos 0.88 BtnWidth BtnHeight], ...
'String','Stop','Tag','btnStop','Callback',cbstrStop, 'Enable', 'off');
%Button : new plot
uicontrol('Parent',h0,'Units','normalized','Position',[xPos 0.82 BtnWidth BtnHeight], ...
'String','New plot','Tag','btnNewPlot','Callback',cbstrNewPlot,'Enable','off');
%Text : parameter range
uicontrol('Parent',h0,'Units','normalized','BackgroundColor',[0.513725 0.6 0.694118], ...
'Position',[xPos 0.74 BtnWidth BtnHeight],'String','Param. range','Style','text');
%Edit : parameter range
edtInitTime = uicontrol('Parent',h0,'Units','normalized','BackgroundColor',[1 1 1], ...
'ForegroundColor',[0 0 1],'Position',[xPos 0.7 BtnWidth BtnHeight],'Style','edit', ...
'Tag','edtParamRg');
%Text : number of points
uicontrol('Parent',h0,'Units','normalized','BackgroundColor',[0.513725 0.6 0.694118], ...
'Position',[xPos 0.62 BtnWidth BtnHeight],'String','Nb. of points','Style','text');
%Edit : number of points
edtInitTime = uicontrol('Parent',h0,'Units','normalized','BackgroundColor',[1 1 1], ...
'ForegroundColor',[0 0 1],'Position',[xPos 0.58 BtnWidth BtnHeight],'Style','edit', ...
'Tag','edtNbPts');
%Text : time range
uicontrol('Parent',h0,'Units','normalized','BackgroundColor',[0.513725 0.6 0.694118], ...
'Position',[xPos 0.5 BtnWidth BtnHeight],'String','Time range','Style','text', ...
'Tag','txtTimeRange');
%Edit : time range
uicontrol('Parent',h0,'Units','normalized','BackgroundColor',[1 1 1], ...
'ForegroundColor',[0 0 1],'Position',[xPos 0.46 BtnWidth BtnHeight],'Style','edit', ...
'Tag','edtTimeRange');
%Text : select variable
uicontrol('Parent',h0,'Units','normalized','BackgroundColor',[0.513725 0.6 0.694118], ...
'Position',[xPos 0.38 BtnWidth BtnHeight],'String','Select variable','Style','text', ...
'Tag','txtSelVar');
%Edit : select variable
uicontrol('Parent',h0,'Units','normalized','BackgroundColor',[1 1 1], ...
'ForegroundColor',[0 0 1],'Position',[xPos 0.34 BtnWidth BtnHeight],'Style','edit', ...
'Tag','edtSelVar');
%Text : initial conditions
uicontrol('Parent',h0,'Units','normalized','BackgroundColor',[0.513725 0.6 0.694118], ...
'Position',[xPos 0.26 BtnWidth BtnHeight],'String','Initial cond.','Style','text');
%Edit : initial conditions
uicontrol('Parent',h0,'Units','normalized','BackgroundColor',[1 1 1], ...
'ForegroundColor',[0 0 1],'Position',[xPos 0.22 BtnWidth BtnHeight],'Style','edit', ...
'Tag','edtInitCond');
%Button : help
uicontrol('Parent',h0,'Units','normalized','Position',[xPos 0.12 BtnWidth BtnHeight], ...
'String','Help','Tag','btnHelp','Callback',cbstrHelp, 'Enable', 'on');
%Button : exit
uicontrol('Parent',h0,'Units','normalized','Position',[xPos 0.06 BtnWidth BtnHeight], ...
'String','Exit','Tag','btnExit','Callback',cbstrExit, 'Enable', 'on');
%Axes
axes('Parent',h0,'Position',[0.07 0.15 0.75 0.75]);
box
%Edit : axes title
uicontrol('Parent',h0,'Units','normalized','BackgroundColor',[1 1 1], ...
'ForegroundColor',[0 0 0],'Position',[0.3 0.915 0.29 0.05],'Style','edit', ...
'Tag','edtTitle');
%Button : browse
uicontrol('Parent',h0,'Units','normalized','Position',[0.593 0.92 0.03 0.04], ...
'Style','pushbutton','String','...','Callback',cbstrBrowse, ...
'Tag','btnBrowse', 'Enable', 'on');
%Text : current values and time
uicontrol('Parent',h0,'Units','normalized','BackgroundColor',[1 1 1], ...
'ForegroundColor',[0 0 1],'Position',[0.0057 0.01 0.835 0.045],'Style','text', ...
'Tag','txtVal');
set(h0,'Visible','on');
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -