# Parametric plot from two NDsolve solutions

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.

Sure you can:

sol1 = NDSolve[{x'[t] == Sin[t], x == 1}, x, {t, 0, 10}];
sol2 = NDSolve[{a'[t] == Cos[t], a == 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}]

• Awesome ssch, thank you so much. – MSB Jun 11 '16 at 3:39

Simply you can use the following command:

sol = NDSolve[{x'[t] == Sin[t], a'[t] == Cos[t], a == 1,
x == 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.

• 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. – Szabolcs Mar 26 '13 at 21:32