2
$\begingroup$

I have a system of differential equations that I'd like to solve for different values of a parameter. I am doing so, by

 Manipulate[
 NDSolve[{D[x[t], t] == 
    c*(3 - 2)*(x[t])^2 y[t] - c*(y[t])^2 x[t] - 1*x[t] + 1*y[t], 
   D[y[t], t] == 
    c*(3 - 2)*(y[t]) x[t] - c*(x[t])^2 y[t] - 1*y[t] + 1*x[t], 
   x[0] == 0.2, y[0] == 0.8}, {x, y}, {t, 0, 100}], {c, 0, 10}]

I then want to plot parametric plots of functions x and y, and plot the functions x and y vs t. For now, I am copying the output and feeding it into the respective plotting functions,

ParametricPlot[{InterpolatingFunction[], InterpolatingFunction[]}, {t, 0, 100}]
Plot[{InterpolatingFunction[], InterpolatingFunction[]}, {t, 0, 100}]

As a Mathematica novice, I was wondering if there is someway to nest these three operations, so that the output gives me the the interpolating functions, and the two plots, and then I can vary the parameter c.

$\endgroup$
  • $\begingroup$ See ParametricNDSolve command. $\endgroup$ – Alx Aug 9 at 3:45
  • 1
    $\begingroup$ So, you change your NDSolve to sol=ParametricNDSolve[...], then Manipulate[ Plot[Evaluate[{x[c][t], y[c][t]} /.sol], {t, 0, 100}, PlotRange -> All], {c, 0, 10}]. $\endgroup$ – Alx Aug 9 at 3:52
3
$\begingroup$
Manipulate[
 Column[{
   sol = NDSolve[{D[x[t], t] == c*(3 - 2)*(x[t])^2 y[t] - c*(y[t])^2 x[t] - 1*x[t] + 1*y[t], 
      D[y[t], t] == c*(3 - 2)*(y[t]) x[t] - c*(x[t])^2 y[t] - 1*y[t] + 1*x[t], 
      x[0] == 0.2, y[0] == 0.8}, {x, y}, {t, 0, 100}],
   ParametricPlot[{x[t], y[t]} /. sol, {t, 0, 100}],
   Plot[{x[t] /. sol, y[t] /. sol}, {t, 0, 100}]
   }],
 {c, 0, 10}]

enter image description here

$\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.