Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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.

share|improve this question

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}]
share|improve this answer

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!

share|improve this answer
    
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. –  Szabolcs Mar 26 '13 at 21:29
1  
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

Your Answer

 
discard

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.