Services & Resources / Wolfram Forums / MathGroup Archive

MathGroup Archive 2012

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

Search the Archive

Re: Wrapping NDSolve within a function

  • To: mathgroup at
  • Subject: [mg126345] Re: Wrapping NDSolve within a function
  • From: "Nasser M. Abbasi" <nma at>
  • Date: Thu, 3 May 2012 04:35:17 -0400 (EDT)
  • Delivered-to:
  • References: <jnqvn6$j5n$>
  • Reply-to: nma at

On 5/2/2012 4:45 AM, bbeckage wrote:
> When I try to return the interpolating function produced by NDSolve from
> within a function, the object returned has an unexpected $7360 appended,
> e.g.,

Symbols defined inside Modules will have $nnnn appended to their names.

Rules of thumbs I use: Do not return symbols defined inside Module
back to the caller. To do what you want, pass these symbols along
with the other call parameters. This way, these symbols will be used
inside the Module.

Also, no need to use Return. By default, the last expression value
is the one returned from a Module. Just make sure there is no
";" at the end of the expression.

predState[rg_, rp_, rh_, Mg_, Mp_, Mh_, g_, p_, q_] :=
   Module[{parmList3woC, parmListND3woC, A, B, Rb, Rc, solND},

    parmListND3woC = {A -> Mg/rg, B -> Mp/rg, C -> Mh/rg, Rb -> rp/rg, Rc -> rh/rg};
     NDSolve[{Derivative[1][g][t] == g[t]*(1 - g[t] - p[t] - q[t]) - A*g[t]*g[t] /.
        parmListND3woC, Derivative[1][p][t] == Rb*p[t]*(1 - p[t] - q[t]) -
          B*p[t]*g[t] /. parmListND3woC, Derivative[1][q][t] ==
         Rc*q[t]*(1 - q[t]) - C*q[t]*g[t] /. parmListND3woC, g[0] == 0.5,
       p[0] == 0.5, q[0] == 0.5}, {g, p, q}, {t, 0, 1000}]





  • Prev by Date: Wrapping NDSolve within a function
  • Next by Date: Re: Struggling to prove simple triangle inequality
  • Previous by thread: Wrapping NDSolve within a function
  • Next by thread: How does one translate a mathematica program into a C# program? eom