Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I have a series of PDE equations that are solved with NDSolve for certain variables $a$ and $b$ - Now, I want to see the output at a time $t$ as $a$ and $b$ change; so I was thinking of a loop formulation, where both variables increment , the PDEs are solved and the output for time $t$ saved.

I am not sure how to implement this in mathematica, or whether it's even the best way to do it - I will eventually want to use the outputs for curve fitting to some data.

Any suggestions would be appreciated!

share|improve this question
?Manipulate and setup a slider for a and b, and click the play arrow. – Nasser Jan 29 '14 at 15:29
It might good to run Table[] in the initialization of Manipulate, save the output to a variable, and have it show the results from that ... depending on how intensive the calcs are. I really don't like putting too much into manipulate. – MRN16 Jan 29 '14 at 15:35
ParametricNDSolve might be the answer to the problem. – Oliver Jennrich Jan 29 '14 at 15:48
Thanks folks; I'll experiment with all these approaches! – DRG Jan 30 '14 at 1:26
Any of the optimizations in this Q&A may apply depending on what your PDEs are: link – C. E. Feb 2 '14 at 13:49

I had to to do the same thing recently:

Let's suppose we want to solve y1'[x] = b^2/a y1 + y2^2, y2'[x]= a y2^2 - b y1^2. Start by defining the module to solve the equation:

solution[a_,b_,t_]:= Module[{xend =t}, 
sol = NDSolve [{y1'[x] == b^2/a y1[x] + y2[x]^2,  y2'[x]== a y2[x]^2 - b y1[x]^2, y1[x1]== Yin, y2[x1]==Yin},{y1, y2}, {x, x1, xend}]; 
Evaluate[y2[xend] /. sol]]

Then you run Table as has been suggested:

t = 20;
mylist = Table [
solution[a, b, t]
,{a,amin, amax, step}, {b, bmin,bmax, bstep}]

You can use an interpolation function to navigate different values of a and b.

Hope it helps, L.

share|improve this answer

Your Answer


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.