3
$\begingroup$
ss1 = NDSolve[{x'[t] == (1 - (x[t]^2 + y[t]^2))*x[t] + ω[t]*y[t] + 1.3*Sin[11*t], 
               y'[t] == (1 - (x[t]^2 + y[t]^2))*y[t] - ω[t]*x[t],
               ω'[t] == 1.3*Sin[11*t]*y[t]/(Sqrt[x[t]^2 + y[t]^2]), 
               x[0] == 1, y[0] == 0, ω[0] == 2}, {x, y, ω}, {t, 0, 200*Pi}];
Animate[
  Show[
    ParametricPlot[
      Evaluate[{x[t], y[t]} /. ss1], {t, tmax - 1, tmax}, 
      PlotStyle -> {Thick, Green}, PlotRange -> 1.4, AspectRatio -> 1, 
      PerformanceGoal -> "Quality"
    ], 
    Graphics[{PointSize[.03], Red, Point@{x[tmax], y[tmax]} /. ss1}, PlotRange -> 1.4], 
    ParametricPlot[
      Evaluate[{x[t], y[t]} /. ss1], {t, 626, 200*Pi}, 
      PlotRange -> 1.2, PlotStyle -> {Thick, Orange}, 
      ImageSize -> Medium, Frame -> True, 
      FrameLabel -> {{Style["V", Bold], None}, {Style["X", Bold], None}}
    ]
  ], 
  {tmax, 1, 200*Pi}, DefaultDuration -> 200 π, AnimationRate -> 0.03
]

I would like to export my animation as a GIF (a good visualization for presentation). I tried a lot of different ways of making it work but unfortunately I could not make it.

$\endgroup$
7
$\begingroup$

I'd just make a set of frames and export those:

frames =
  Table[
   Show[
    ParametricPlot[Evaluate[{x[t], y[t]} /. ss1], {t, tmax - 1, tmax}, 
     PlotStyle -> {Thick, Green}, PlotRange -> 1.4, AspectRatio -> 1, 
     PerformanceGoal -> "Quality"], 
    Graphics[{PointSize[.03], Red, Point@{x[tmax], y[tmax]} /. ss1}, 
     PlotRange -> 1.4], 
    ParametricPlot[Evaluate[{x[t], y[t]} /. ss1], {t, 626, 200*Pi}, 
     PlotRange -> 1.2, PlotStyle -> {Thick, Orange}, ImageSize -> Medium, 
     Frame -> True, 
     FrameLabel -> {{Style["V", Bold], None}, {Style["X", Bold], None}}]],
   {tmax, 1, 200*Pi, 10}
   ];

Export["~/Desktop/test.gif", 
 frames, 
 "DisplayDurations" -> .1,
 "AnimationRepetitions" -> Infinity
 ]

enter image description here

You can increase the number of frames for a smoother animation

$\endgroup$

Your Answer

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

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