Question
In Matlab: BifurcDiagramDriver.m: %This m-file will run through a loop to create a bifurcation diagram %derivs = 'saddlenode'; saddlenodehandle = @saddlenode; check_function = isa(saddlenodehandle, 'function_handle');
In Matlab:
BifurcDiagramDriver.m:
%This m-file will run through a loop to create a bifurcation diagram %derivs = 'saddlenode'; saddlenodehandle = @saddlenode; check_function = isa(saddlenodehandle, 'function_handle'); if ~check_function fprintf('ERROR: Did not get handle to function. '); end dim=1; y_init = -0.1; T0 = 0; Tspan = [0 20]; count=0; rrange=[-5:0.1:0.0]; %Change this as appropriate for given bifurcation type %Try to eliminate ranges where solution shoots off %to infinity ysave=[ ]; for r=-5:0.1:0.0 %set this equal to the rrange values above clear t; clear y; [t,y]=ode45(@(t,y)saddlenodehandle(t,y,r),Tspan,y_init); count = count+1; ysave(count,:) = y(end,:); end plot(rrange,ysave); %Next see if we can reverse time and find the unstable branches saddlenodehandle2 = @saddlenode_revT; check_function2 = isa(saddlenodehandle2, 'function_handle'); if ~check_function2 fprintf('ERROR: Did not get handle to function. '); end count=0; y_init=0; rrange2=[-5:0.1:0.0]; ysave_unstable = [ ]; for r=-5.0:0.1:0.0 clear t; clear y; [t,y]=ode45(@(t,y)saddlenodehandle2(t,y,r),Tspan,y_init); count = count+1; ysave_unstable(count,:) = y(end,:); end if (length(rrange2)==length(ysave_unstable)) hold on,plot(rrange2,ysave_unstable,'r-'); else LL=length(ysave_unstable) figure,plot(ysave_unstable) end
return
saddlenode.m:
function ydot = saddlenode(t,y,r) %This m-file contains the derivs for a first order DE which undergoes a saddle- %node bifurcation as r varies. ydot = [y.*y+r];
2. Now modify these programs to produce the other types of one-dimensional bifurcation diagrams: transcritical, subcritical pitchfork and supercritical pitchfork. You may need to change y _init to see each branch, as well as the range of the control parameter. Print these out and label each branch with its stabilityStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started