0
$\begingroup$

I am trying to use manipulate with a plot of a numerical solution to a system of two coupled differential equation solved using ParametricNDSolveValue. I have successfully been able to use ParametricPlot inside the Manipulate expression to plot the two-dimensional trajectory of the system. However, when I try to make a one-dimensional plot of only one of the solutions, the plot crashes after a little bit of use.

Could someone tell me why the seemingly more complex two-dimensional plot works and the one-dimensional one does not.

solution = 
  ParametricNDSolveValue[
    {x'[t] - Q*y[t] - A == 0, y'[t] + Q*x[t] == 0, 
     x[0] == 1/Sqrt[2], y[0] == 1/Sqrt[2]}, 
    {x, y}, {t, 0, 10000}, {Q, A}]

The following works:

Manipulate[
  ParametricPlot[Evaluate[#[t] & /@ solution[Q, A]], {t, 0, 1000}, 
    PlotRange -> {{-1.5, 1.5}, {-1.5, 1.5}}, 
    ImageSize -> 600], 
  {Q, 0, 0.5}, 
  {A, 0, 1}, 
  TrackedSymbols :> {Q, A}]

The following crashes:

Manipulate[
  Plot[Evaluate[#[t] & /@ solution[Q, A]][[1]], {t, 0, 100}, 
    PlotRange -> {{0, 100}, {-2, 2}}], 
  {Q, 0,0.5}, 
  {A, 0, 1}, 
  TrackedSymbols :> {Q, A}]
$\endgroup$
  • 1
    $\begingroup$ Just take what part of solution you need: Manipulate[Plot[Evaluate@solution[Q, A][[1]][t], {t, 0, 100}, PlotRange -> {{0, 100}, {-2, 2}}], {Q, 0, 0.5}, {A, 0, 1},TrackedSymbols :> {Q, A}] $\endgroup$ – Alx Sep 6 '19 at 0:59

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.