I have two independent ODE systems.

A = NDsolve[..., {x, y}, {t, 0, 10}];
B = NDsolve[..., {a, b}, {t, 0, 10}];

I can draw a ParametricPlot from one ODE. That is,

ParametricPlot[Evaluate[{x[t], y[t]} /. A], {t, 0, 10}]

I wonder if I can draw a ParametricPlot from the two independent ODE systems. That is a ParametricPlot of x[t] taken from A and a[t] taken from B.


2 Answers 2


Sure you can:

sol1 = NDSolve[{x'[t] == Sin[t], x[0] == 1}, x, {t, 0, 10}];
sol2 = NDSolve[{a'[t] == Cos[t], a[0] == 1}, a, {t, 0, 10}];
ParametricPlot[Evaluate[{x[t], a[t]} /. Flatten@{sol1, sol2}], {t, 0, 10}]

The Flatten is there for the following reason:

{x[t], a[t]} /. {sol1, sol2}
(* {{{InterpolatingFunction[{{0.,10.}},<>][t],a[t]}},   
   {{x[t],InterpolatingFunction[{{0.,10.}},<>][t]}}} *)
{x[t], a[t]} /. Flatten@{sol1,sol2}
(* {InterpolatingFunction[{{0.,10.}},<>][t],
    InterpolatingFunction[{{0.,10.}},<>][t]} *)

You can also do:

ParametricPlot[Evaluate[{x[t] /. First@sol1, a[t] /. First@sol2}], {t, 0, 10}]
  • $\begingroup$ Awesome ssch, thank you so much. $\endgroup$
    – MSB
    Commented Jun 11, 2016 at 3:39

Simply you can use the following command:

sol = NDSolve[{x'[t] == Sin[t], a'[t] == Cos[t], a[0] == 1, 
    x[0] == 1}, {x, a}, {t, 0, 10}];

ParametricPlot[{x[t], a[t]} /. sol, {t, 0, 10}, 
 AxesLabel -> {x[t], a[t]}]

Firstly, you may consider one system so as to use the NDSolve only one time and then use the ParametricPlot. It is the same if you add the equations y[t] and b[t], as you say in your question.

So your conclutions are right!

  • $\begingroup$ Welcome to Mathematica.SE! I formatted your answer a bit for readability. You can check how I did this by clicking the edit link just below your post. You can also use the ? button in the top right corner of the editor to learn about how to format posts. $\endgroup$
    – Szabolcs
    Commented Mar 26, 2013 at 21:29
  • 1
    $\begingroup$ While theoretically it's always possible to treat two separate ODEs as one system, this may not always be beneficial. NDSolve can use methods with an adaptive step size, and if you solve two equations as one system, then the same step sizes will be used for both. I'm not exactly sure how the step size is determined. Most likely the only "ill" effect will be that the two questions will be evaluated more than necessary. $\endgroup$
    – Szabolcs
    Commented Mar 26, 2013 at 21:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.