⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bifurcation.m

📁 一个混沌信号产生器MATLAB源代码.主要用于产生混沌信号序列
💻 M
📖 第 1 页 / 共 2 页
字号:
function bifurcation(action)
%
%Bifurcation - grafical interface for bifurcation ploting
%
%	Click "Start" button in order to begin the simulation.
%   You can stop the simulation at any time by pressing the "Stop"
%   button.
%   Using the "New plot" button a new figure is displayed with the obtained
%   bifurcation.
%   "Help" button displays this message.
%   Use "Exit" button in order to close the graphical interface and clear
%   all used variables.
%
%   A time discrete chaotic generator can be selected in the upper part of the graphical
%   interface. Use the "..." (browse) button in order to select a
%   specific chaotic generator from the list.
%
%   From the graphical interface the following parameters can be modified:
%   - Param. range: range of the parameter of the chaotic generator ;
%   - Nb. of points: number of points used for each parameter value in
%   order to construct the bifurcation diagram;
%   - Plotting style: "0" use dots and "1" use a continuous line for plotting
%   the attractor;
%   - Time range: discrete time range for the state variable of the chaotic
%   generator;
%   - Select variable: state variable used to plot the bifurcation diagram;
%   - Initial cond: initial conditions for the chaotic generator;
%
%	In the bottom of the figure is displayed current value of the parameter
%
%   The available time discrete chaotic generators are:
%      - BernoulliMap: Bernoulli map
%           x[n] = mod(k*x[n-1], 1)
%           where k arbitrary
%      - genhaos: chaos generator with a recursive structure
%           x[n] = f(k[1]*x[n-1]+k[2]*x[n-2]+k[3]*x[n-3])
%           where f(x) = x-2*floor((x+1)/2), k[1] arbitrary, k[2] = k[3] = 1
%      - henonmap: Henon map
%           x[n] = 1-alpha*x[n-1]^2+y[n-1];
%           y[n] = beta*x[n-1];
%           where alpha arbitrary, beta = 0.3
%      - logisticmap1: logistic like map 1
%           x[n] = (k^2)*x[n-1]*(1-x[n-1])*((1-2*x[n-1])^2);
%           where k arbitrary
%      - logisticmap2: logistic like map 2
%           x[n] = k*x[n-1]*(0.75-(x[n-1]^2))
%           where k arbitrary
%      - logisticmap3: logistic like map 3
%           x[n] = k*x[n-1]*(1.25-(5*(x[n-1]^2))+(4*(x[n-1]^4)))
%           where k arbitrary
%      - logisticmap: logistic map
%           x[n] = k*x[n-1]*(1-x[n-1])
%           where k arbitrary
%      - miramap: Mira map
%           x[n] = y[n-1]
%                          /
%                          | -a*x[n-1]                 , if x[n-1]<6
%           y[n] = y[n-1]+ |
%                          | lambda*x[n-1]-6*(a+lambda), otherwise
%                          \
%           where a arbitrary, lambda = 2
%      - PWAMmap1: piece wise affine Markov map 1
%                  /
%                  | B*(D-abs(x[n-1]))   , if abs(x[n-1])<=D
%           x[n] = |
%                  | B*(abs(x[n-1])-2*D) , otherwise
%                  \
%           where B arbitrary, D = 1
%      - PWAMmap2: piece wise affine Markov map 2
%                  /
%                  | -B*abs(x[n-1])       , if abs(x[n-1])<=D
%           x[n] = |
%                  | -B*(abs(x[n-1])-2*D) , otherwise
%                  \
%           where B arbitrary, D = 1
%      - PWAMmap3: piece wise affine Markov map 3
%                  /
%           x[n] = | -B*x[n-1]                   , if abs(x[n-1])<=D
%                  | B*(x[n-1]-2*D*sign(x[n-1])) , otherwise
%                  \
%           where B arbitrary, D = 1           
%      - PWAMmap4: piece wise affine Markov map 4
%                  /
%                  | B*(-x[n-1]+D*sign(x[n-1]))  , if abs(x[n-1])<=D
%           x[n] = |
%                  | B*(x[n-1]-2*D*sign(x[n-1])) , otherwise
%                  \
%           where B arbitrary, D = 1           
%      - TailedTentMap: tailed tent map
%           x[n] = 1-2*abs(x[n-1]-((1-k)/2))+max(x[n-1]-1+k,0)
%           where k arbitrary
%      - tentmap1: tent like map 1
%                  /
%                  | k*x[n-1]       , if (0<=x[n-1]) & (x[n-1]<1/3)
%           x[n] = | k*(2/3-x[n-1]) , if (1/3<=x[n-1]) & (x[n-1]<2/3)
%                  | k*(-2/3+x[n-1]), otherwise
%                  \
%           where k arbitrary
%      - tentmap2: tent like map 2
%                  /
%                  | k*x[n-1]             , if (0<=x[n-1]) & (x[n-1]<1/4)
%           x[n] = | sqrt(k)*(1-2*x[n-1]) , if (1/4<=x[n-1]) & (x[n-1]<1/2)
%                  | sqrt(k)*(2*x[n-1]-1) , if (1/2<=x[n-1]) & (x[n-1]<3/4)
%                  | k*(1-x[n-1])         , otherwise
%                  \
%           where k arbitrary
%      - tentmap: tent map
%           x[n] = k*(1-abs(1-2*x[n-1]))
%           where k arbitrary

if nargin==0
	
   %set paths 
   addpath([pwd '\Discr']);
   addpath([pwd '\Prvt']);
   %initialize GUI
   srtBifurcationGUI;
   %set default generator (logisticmap)
%    d=dir('Discr');
%    str = {d.name};
%    s=cell2struct(str(3),{'str'},1);
%    fcname=s.str(1:end-2);
   fcname = 'logisticmap';
   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
elseif strcmp(action,'Start')
   hndf=gcf;
   %set buttons
   set(findobj(hndf,'Tag','btnStop'), 'Enable', 'on');
   set(findobj(hndf,'Tag','btnNewPlot'), 'Enable', 'off');
   set(findobj(hndf,'Tag','btnExit'), 'Enable', 'off');
   set(findobj(hndf,'Tag','btnBrowse'), 'Enable', 'off');
   %get current values
   fcname=get(findobj(hndf,'Tag','edtTitle'),'String');
   vParamRg=str2num(get(findobj(hndf,'Tag','edtParamRg'),'String'));
   nNbPts=str2num(get(findobj(hndf,'Tag','edtNbPts'),'String'));
   vTimeRange=str2num(get(findobj(hndf,'Tag','edtTimeRange'),'String'));
   nSelVar=str2num(get(findobj(hndf,'Tag','edtSelVar'),'String'));
   y0=str2num(get(findobj(hndf,'Tag','edtInitCond'),'String'));
   %bifurcation
   ud.xpts=[];
   ud.ypts=[];
   ud.stop=0;
   for k_var=vParamRg(1):(vParamRg(2)-vParamRg(1)+1)/nNbPts:vParamRg(2)
	    %solver
   		[T,Y]=m_dreTF(fcname,vTimeRange,y0,k_var);
		xutil=Y(1,nSelVar);
		%eliminate redundant points
		for n=2:length(Y(:,nSelVar))
			if xutil~=Y(n,nSelVar)
				xutil=[xutil;Y(n,nSelVar)];
			end
		end
		ud.xpts=[ud.xpts; k_var*ones(length(xutil),1)];
		ud.ypts=[ud.ypts; xutil];
		set(gcf,'UserData',ud)
		if k_var==vParamRg(1)
    		hpts=plot(ud.xpts,ud.ypts,'.','MarkerSize',1,'EraseMode','none');
			set(gca,'XLimMode','manual','YLimMode','manual')
			xmin=min(ud.xpts);
			xmax=max(ud.xpts)+0.1;
			ymin=min(ud.ypts)-0.1;
			ymax=max(ud.ypts)+0.1;
			axis([xmin xmax ymin ymax])
		else
			xlim = get(gca,'xlim');
    		ylim = get(gca,'ylim');
			%replot everything if out of axis range
			if (k_var < xlim(1)) | (xlim(2) < k_var) | (min(xutil) < ylim(1)) | (ylim(2) < max(xutil))
				xmin=xlim(1);
				xmax=xlim(2);
				ymin=ylim(1);
				ymax=ylim(2);
    			if k_var < xlim(1)
					xmin=k_var-0.1;
				elseif xlim(2) < k_var

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -