Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2007

[Date Index] [Thread Index] [Author Index]

Search the Archive

NDSolve, Do loop, and Plot

  • To: mathgroup at
  • Subject: [mg77160] NDSolve, Do loop, and Plot
  • From: DBK <boydkramer at>
  • Date: Tue, 5 Jun 2007 06:34:48 -0400 (EDT)

This seems like it should be easy, but it is giving me problems. I am
running some simulations and would like to simply substitute in a
different parameter value (w below)  for each run of the simulation. I
would then like to separately plot each variable (x and y below) for
each simulation run with a different value for w. My code is below.
When run, I get no error messages but no plot as well. I've tried
pulling the Plot function out of the Do Loop but had no luck.

Also, related to this, is it possible to provide mathematica with
specific values of w instead of a range of values? For example, say I
want to evaluate the simulation at w=2,5, and 14 instead of 2,3,4 as

$TextStyle = {FontFamily -> "Arial", FontSize -> 12,
   FontSlant -> "Italic"};
Do[mysol[w] =
  NDSolve[{x'[t] == -y[t] - x[t]^2, y'[t] == w x[t] - y[t]^3,
    x[0] == y[0] == 1}, {x, y}, {t, 20}];
 Plot[{Evaluate[x[t] /. mysol[w]], Evaluate[y[t] /. mysol[w]]}, {t, 0,
    20}], {w, 2, 4}]

  • Prev by Date: modify elements of arb.dimensionality matrices
  • Next by Date: Re: Latex and \sum
  • Previous by thread: Re: modify elements of arb.dimensionality matrices
  • Next by thread: Re: NDSolve, Do loop, and Plot