Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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.

share|improve this question
    
what is d .....? –  Nasser Feb 11 at 4:46
    
Woops, d = 0.1; –  user12289 Feb 11 at 4:46

1 Answer 1

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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