Search All of the Math Forum:
Views expressed in these public forums are not endorsed by
Drexel University or The Math Forum.


Torsten
Posts:
1,548
Registered:
11/8/10


Re: Loop for bifurcartion in ODE45 !!
Posted:
Jan 21, 2013 3:08 AM


On 20 Jan., 23:47, "Paulo " <biom...@yahoo.com.br> wrote: > Hello! > > I've been trying a few days by now to plot a bifurcation diagram using ODE45, but althought the logic seems correct I could not do it nor find what Iam missing, please help ! > > I'm using two files: > >  The firs m file calls the Ode 45: > > ci=[8 2]; > tspan=[0 1500]; > [t,y] = ode45(@pfunction, tspan, ci); > >  The second m file defines the functions, and has a loop for r1 to plot against y(1), trying for the bifurcations plot: > > function [yout] = pfunction(t,y) > > K1=50; ;Th1=1;a1=.04; > q=0.02; > > for r1=1.8:0.005:2.5 > FC11=(1(y(1)/K1)); %logistic function for prey > RF161=(a1*y(1)/(1+a1*Th1*y(1))); > > %__________________________________________________________ > % PREDADOR 6  y(6) > c61=0.1; > > FC6=(c61*RF161); > > %_________________________________________________________ > > yout = [r1 * y(1) * ((FC11)) (y(2)*RF161); > > FC6 * y(2)  q*y(2);]; > > plot(r1,y(1)) > hold on > end > ______________ > > Thank you very much! > > regards, > Paulo.
You must not loop over r1 in pfunction, but in the calling program for ODE45.
ci=[8 2]; tspan=[0 1500]; For r1=1.8:0.005:2.5 [t,y] = ode45(@(t,y)pfunction(t,y,r1), tspan, ci); % Save solution for r1 end
function [yout] = pfunction(t,y,r1)
K1=50; ;Th1=1;a1=.04; q=0.02; FC11=(1(y(1)/K1)); %logistic function for prey RF161=(a1*y(1)/(1+a1*Th1*y(1))); % PREDADOR 6  y(6) c61=0.1; FC6=(c61*RF161); yout = [r1 * y(1) * ((FC11)) (y(2)*RF161); FC6 * y(2)  q*y(2)];
Best wishes Torsten.



