Mathematica 9 is now available
Student Support Forum
-----
Student Support Forum: 'Solving LV Equations using NDSolve problem' topicStudent Support Forum > General > "Solving LV Equations using NDSolve problem"

Next Comment >Help | Reply To Topic
Author Comment/Response
Janek
11/11/12 1:35pm

hello everybody,
I am trying to solve Lotka-Volterra equations using this code:
ClearAll["Global`*"];
r1 = {x'[t] == x[t] (K - x[t] - a y[t])};
r2 = {y'[t] == y[t] (L - y[t] - b x[t])};
init1 = {x[0] == 0};
init2 = {y[0] == 0};
alpha[K_: 1, L_: 1, a_: 1; b_: 1] := NDSolve[{r1, r2, init1, init2},
{x[t], y[t]}, {t, 0, 30}]

Plot[{Evaluate[x[t], y[t] /. alpha[1, 1, 1, 1]]},
{t, 0, 30}, PlotRange -> All]
All I got is "ReplaceAll::reps: {alpha[1,1,1,1]} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing." error message.
What am I doing wrong?
Cheers and thank you in advance

URL: ,

Subject (listing for 'Solving LV Equations using NDSolve problem')
Author Date Posted
Solving LV Equations using NDSolve problem Janek 11/11/12 1:35pm
Re: Solving LV Equations using NDSolve problem Nasser M. Ab... 11/11/12 11:47pm
Next Comment >Help | Reply To Topic