- #1

mummerta

- 4

- 0

I am trying to solve a system of differential equations and plot solution curves. The differential equations have parameters. I would like to write a loop for these parameters and have the solution curves plot.

Here is my code for the solving / plotting. The parameters I want to change are are currently 7 and 4.

sol = NDSolve[{x'[t] == -7*x[t] y[t] + 4 y[t],

y'[t] == 7*x[t] y[t] - 4 y[t], x[0] == 50, y[0] == 10}, {x,

y}, {t, 0, 10}]

Plot[Evaluate[x[t] /. sol], {t, 0, 1}, PlotRange -> All]

Plot[Evaluate[y[t] /. sol], {t, 0, 1}, PlotRange -> All]

ParametricPlot[Evaluate[{x[t], y[t]} /. sol], {t, 0, 10},

PlotRange -> All]

{x[10], y[10]} /. sol

I don't know how to create a loop (or even which type of loop to use) that will output a plot for each new parameter value.

Any advice that you have to offer would be much appreciated.

Here is my code for the solving / plotting. The parameters I want to change are are currently 7 and 4.

sol = NDSolve[{x'[t] == -7*x[t] y[t] + 4 y[t],

y'[t] == 7*x[t] y[t] - 4 y[t], x[0] == 50, y[0] == 10}, {x,

y}, {t, 0, 10}]

Plot[Evaluate[x[t] /. sol], {t, 0, 1}, PlotRange -> All]

Plot[Evaluate[y[t] /. sol], {t, 0, 1}, PlotRange -> All]

ParametricPlot[Evaluate[{x[t], y[t]} /. sol], {t, 0, 10},

PlotRange -> All]

{x[10], y[10]} /. sol

I don't know how to create a loop (or even which type of loop to use) that will output a plot for each new parameter value.

Any advice that you have to offer would be much appreciated.

Last edited: