WICHTIG: Der Betrieb von goMatlab.de wird privat finanziert fortgesetzt. - Mehr Infos...

Mein MATLAB Forum - goMatlab.de

Mein MATLAB Forum

 
Gast > Registrieren       Autologin?   

Partner:




Forum
      Option
[Erweitert]
  • Diese Seite per Mail weiterempfehlen
     


Gehe zu:  
Neues Thema eröffnen Neue Antwort erstellen

Lotka Volterra

 

Javier031
Forum-Newbie

Forum-Newbie


Beiträge: 2
Anmeldedatum: 01.01.17
Wohnort: ---
Version: ---
     Beitrag Verfasst am: 02.01.2017, 00:11     Titel: Lotka Volterra
  Antworten mit Zitat      
Hello everyone, I need to solve this problem in octave using the euler´s method (forward euler and backward euler) but I am not able. I was recommended this forum and was told that there were very smart people. If you could help me I would be very grateful. Very Happy

Here is the problem:http://www.gomatlab.de/files/doc2_536.pdf

Here is the equation:http://www.gomatlab.de/files/captura2_566.jpg

Here is mi forward euler program:http://www.gomatlab.de/files/captura1_465.jpg

Thank you for your help. Wink

Doc2.pdf
 Beschreibung:

Download
 Dateiname:  Doc2.pdf
 Dateigröße:  163.04 KB
 Heruntergeladen:  428 mal
Captura1.JPG
 Beschreibung:

Download
 Dateiname:  Captura1.JPG
 Dateigröße:  24.26 KB
 Heruntergeladen:  534 mal
Captura2.JPG
 Beschreibung:

Download
 Dateiname:  Captura2.JPG
 Dateigröße:  48.64 KB
 Heruntergeladen:  527 mal
Private Nachricht senden Benutzer-Profile anzeigen


Jan S
Moderator

Moderator


Beiträge: 11.057
Anmeldedatum: 08.07.10
Wohnort: Heidelberg
Version: 2009a, 2016b
     Beitrag Verfasst am: 02.01.2017, 21:01     Titel: Re: Lotka Volterra
  Antworten mit Zitat      
Hallo Javier031,

Please post the code as text and not as a screen shot. Then the readers can modify and test the code by copy&paste and do not have to type it again.

What is your question? What does your code do?

Kind regards, Jan
Private Nachricht senden Benutzer-Profile anzeigen
 
Javier031
Themenstarter

Forum-Newbie

Forum-Newbie


Beiträge: 2
Anmeldedatum: 01.01.17
Wohnort: ---
Version: ---
     Beitrag Verfasst am: 02.01.2017, 23:01     Titel: Re: Lotka Volterra
  Antworten mit Zitat      
Sorry Jan S, my problem is to calculate the amount of population of predators and prey over time and the equation is Lotka-volterra type.

Here´s my problem: The Lotka-Volterra system of di erential equations is commonly used to model the evolution of two populations of predators NP and prey Np. The
following hypotheses hold:
1. Prey population increases proportionally to the number of prey (with
constant 'alpha') but is destroyed by predators at a rate proportional to the prod-
uct of the numbers of prey and predators (with constant 'beta' ).
2. Predator population decreases at a rate proportional to the number of
predators, but increases at a rate again proportional to the product of the
numbers of prey and predators. The constants associated to each event are
'gamma' and 'delta', respectively.

Solve the systems of ODES up to t=15
- Find by trial and error an adequate time step.
-Plot the time evolution of both populations.
-Plot the populations of predators vs. the population of prey.

HELP:
A matlab code for integration of systems of ODE using Forward-Euler is
provided

Here´s my function:
Code:
function y=growth(u,v,t)
%Data:
Prey=70000;
Predator=20000;
alpha=1.2;
beta=0.00006;
gamma=0.8;
delta=0.00005;
endtime=15;
  if (t<???)
    fun=inline('Prey*(alpha-beta*Predator)');  %first equation
  else
    fun=inline('Predator*(delta*Prey-gamma)'); %second equation
  end
end


And here my forward-euler code:

Code:
function [t,u,v]=forward_euler(fun,u0,v0, t0, tf, n)

u0=70000;
v0=20000;
t0=0;
tf=15;
n=10;
u=70000;
v=20000;

h=(tf-t0)/n;
u(1)=u0;
v(1)=v0;
t(1)=t0;

if (t<2.5)
fun=inline('u*(1.2-0.00006*v)');
else
fun=inline('v*(0.00005*u- 0.8 )');
end

    for i=2:n+1
        deriv1=feval(fun,u(i-1),v(i-1),t(i-1));
        u(i)=u(i-1)+h*deriv1;
        v(i)=v(i-1)*h*deriv1;
        t(i)=t(i-1)+h;
    end
 

They should leave lotka-volterra type graphics like this (http://www.gomatlab.de/files/captura3_367.jpg) and instead I get exponential graphs, but I do not know where I made the mistake or the time step I have to use to do it .

Please I need help, if anyone knows how to solve it I would be very grateful. I guess it is not difficult to do but my knowledge of matlab is limited.

[EDITED, Jan, Please use the Code formatting - Thanks!]

Captura3.JPG
 Beschreibung:

Download
 Dateiname:  Captura3.JPG
 Dateigröße:  72.73 KB
 Heruntergeladen:  535 mal
Private Nachricht senden Benutzer-Profile anzeigen
 
Neues Thema eröffnen Neue Antwort erstellen



Einstellungen und Berechtigungen
Beiträge der letzten Zeit anzeigen:

Du kannst Beiträge in dieses Forum schreiben.
Du kannst auf Beiträge in diesem Forum antworten.
Du kannst deine Beiträge in diesem Forum nicht bearbeiten.
Du kannst deine Beiträge in diesem Forum nicht löschen.
Du kannst an Umfragen in diesem Forum nicht mitmachen.
Du kannst Dateien in diesem Forum posten
Du kannst Dateien in diesem Forum herunterladen
.





 Impressum  | Nutzungsbedingungen  | Datenschutz | FAQ | goMatlab RSS Button RSS

Hosted by:


Copyright © 2007 - 2024 goMatlab.de | Dies ist keine offizielle Website der Firma The Mathworks

MATLAB, Simulink, Stateflow, Handle Graphics, Real-Time Workshop, SimBiology, SimHydraulics, SimEvents, and xPC TargetBox are registered trademarks and The MathWorks, the L-shaped membrane logo, and Embedded MATLAB are trademarks of The MathWorks, Inc.