Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

How to plot the result of NDSolve?

  1. Jul 5, 2012 #1
    1) I solved 9 coupled non linear differential equation and Mathematica give me the result like this.

    {{y1[t]->InterpolatingFunction[{{0.001,0.01}},<>][t],
    y2[t]->InterpolatingFunction[{{0.001,0.01}},<>][t],
    y3[t]->InterpolatingFunction[{{0.001,0.01}},<>][t],
    y4[t]->InterpolatingFunction[{{0.001,0.01}},<>][t],
    y5[t]->InterpolatingFunction[{{0.001,0.01}},<>][t],
    y6[t]->InterpolatingFunction[{{0.001,0.01}},<>][t],
    y7[t]->InterpolatingFunction[{{0.001,0.01}},<>][t],
    y8[t]->InterpolatingFunction[{{0.001,0.01}},<>][t],
    y9[t]->InterpolatingFunction[{{0.001,0.01}},<>][t]}}


    How can I plot each of the function (y1 to y9) separately?

    2) To solve a single differential equation (refer to the Mathematica NDSolve Help) and plot it, why we must divide by the answer itself? I mean, in this case, why should I divide by " .s " ?

    s = NDSolve[{y'[x] == y[x] Cos[x + y[x]], y[0] == 1}, y, {x, 0, 30}]

    Plot[Evaluate[y[x] /. s], {x, 0, 30}, PlotRange -> All]
     
  2. jcsd
  3. Jul 5, 2012 #2

    chiro

    User Avatar
    Science Advisor

    Hey panzer7910 and welcome to the forums.

    Upon looking into the documentation, the expression with the s has to do with expression simplification. Remember that you have an Evaluate command nested within, and this will evaluate an expression with your ./ s parameter.

    What looks to be happening is that it is making a substitution so that the function actually gets evaluated instead of having a purely symbolic representation, but I would double check.

    http://reference.wolfram.com/mathematica/guide/Expressions.html

    http://reference.wolfram.com/mathematica/ref/ReplaceAll.html

    http://reference.wolfram.com/mathematica/guide/Rules.html

    http://reference.wolfram.com/mathematica/ref/ReplaceAll.html
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: How to plot the result of NDSolve?
Loading...