A New Kind of Science: The NKS Forum > Pure NKS > A plotting question
Author
Edwin

Registered: May 2006
Posts: 1

A plotting question

I cannot figure out how to produce a parametric plot of the "interpolating function" output resulting from using an NDSolve command. Can anyone help?

I appreciate any suggestions.

Report this post to a moderator | IP: Logged

05-25-2006 07:57 PM
Jason Cawley
Wolfram Science Group
Phoenix, AZ USA

Registered: Aug 2003
Posts: 712

First, this forum is meant for New Kind of Science discussions. General Mathematica questions are better directed to Mathgroup, which you can find from here -

http://forums.wolfram.com/mathgroup/

Second, I'm not sure what you are trying to do, but an example might be all you need. If so, here is one -

mysolution =
NDSolve[{x'[t] == -y[t] - x[t]^2, y'[t] == 2 x[t] - y[t]
x[0] == y[0] == 1}, {x, y}, {t, 0, 10}]

That returns an interpolating function object, stored in the variable name "mysolution". ParametricPlot needs to be called in a form that gives it an {x,y} value for each value of its parameter variable, which you can get from e.g. -

ParametricPlot[{x[t], y[t]} /. mysolution, {t, 0, 10},
PlotRange -> All]

Note the construction  /.mysolution . Interpolating function objects are effectively rules to replace their LHS variable names with tables of data. "/." means "ReplaceAll", meaning apply the following rules wherever their LHS's occur in the expression preceding.

Occasionally it may help to wrap the function Evaluate around the first argument in that call to ParametricPlot - from {x[t] to the end of mysolution in the line above, inside the brackets of the Evaluate - but it is not necessary in simple cases.

I hope this helps.

Report this post to a moderator | IP: Logged

05-25-2006 09:39 PM

wolframscience.com  |  wolfram atlas  |  NKS online  |  Wolfram|Alpha  |  Wolfram Science Summer School  |  web resources  |  contact us