Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.matlab

Topic: Loop for bifurcartion in ODE45 !!
Replies: 1   Last Post: Jan 21, 2013 3:08 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
Torsten

Posts: 1,457
Registered: 11/8/10
Re: Loop for bifurcartion in ODE45 !!
Posted: Jan 21, 2013 3:08 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

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.



Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.