0
$\begingroup$

I'm working on a system that has molecular interactions, for which I have the defined constants.

r=0.5;
a=1;
c=0.01;
d=0.1;
e=0.02;
k=500;

and my system of differential equations, which was solved numerically using NDSolve

I put the following:

sol == NDSolve[{
            x’[t] == r*x[t]*(1-(x[t]/k)) – a*c*x[t]*y[t], 
            y’[t] == a*c*x[t]*y[t] – d*y[t],
            x[0] == y[0] == 30
            }, {x,y}, {t,1000}
       ]

and received the following:

{{xInterpolatingFunction[{{0.,1000.}},< >], yInterpolatingFunction[{{0.,1000.}} < > ] }}

Then, I put in

Plot[Evaluate[{y[t],x[t]}/.sol],{t,0,1000},PlotRange{0,500}]

for which I received a beautiful plot of both y[t] and x[t] over the course of time t.

However, for purposes of stability, I want to plot y[t] on the y axis and x[t] on the x axis for a range of 0 to 250 on the y axis and about 0 to 1000 on the x axis.

How would I go about doing this?

I thought about

Plot[Evaluate[{y[t],x[t]}/.sol],{x,0,1000},PlotRange{0,500}]

....but I received no success. Just a blank plot.

$\endgroup$
  • $\begingroup$ what is d .....? $\endgroup$ – Nasser Feb 11 '14 at 4:46
  • $\begingroup$ Woops, d = 0.1; $\endgroup$ – user12289 Feb 11 '14 at 4:46
6
$\begingroup$

Use ParametricPlot

Clear[x, y, t];
r = 0.5; a = 1; c = 0.01; e = 0.1; k = 500; d = 0.1;
sol = NDSolve[{x'[t] == r x[t] (1 - x[t]/k) - a c x[t] y[t], 
   y'[t] == a c x[t] y[t] - d y[t], x[0] == 30, y[0] == 30}, {x, y}, {t,1000}];

ParametricPlot[Evaluate[{y[t], x[t]} /. sol], {t, 0, 1000}, Frame -> True, 
      ImagePadding -> 40, ImageSize -> 300, AspectRatio -> Automatic, 
FrameLabel -> {{"y(t)", None}, {"x(t)", "my phase plane plot"}}]

Mathematica graphics

If you want to reverse the functions

ParametricPlot[Evaluate[{x[t], y[t]} /. sol], {t, 0, 1000}, Frame -> True, 
   ImagePadding -> 40, ImageSize -> 300,  AspectRatio -> Automatic, 
   FrameLabel -> {{"x(t)", None}, {"y(t)", "my phase plane plot"}}]

Mathematica graphics

To adjust ranges, you can use the PlotRange option

ParametricPlot[Evaluate[{x[t], y[t]} /. sol], {t, 0, 1000}, 
   PlotRange -> {{0, 25}, {0, 100}}]

As needed.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.