4
$\begingroup$

This question already has an answer here:

I want to export a simple animation as GIF. I had a look at here but could not understand what was being described. Any help would be appreciated.

For instance, how do I export the following animation as an GIF.

u[x_, t_] = -(1/2) Cos[x - t]^2 + 1;

Animate[Plot[u[x, t],{x, -10, 10},PlotRange->{0, 1.5},PlotStyle->{Red, Thickness[0.005]}],{t, 0, 10, 0.02}]

Thanks, Radz.

$\endgroup$

marked as duplicate by Mark McClure, ybeltukov, RunnyKine, bobthechemist, Michael E2 Aug 28 '14 at 17:40

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

5
$\begingroup$

Simply replace Animate with Table and store the result in a variable. I also edited your time range and suppressed the result with a semi-colon.

u[x_, t_] = -(1/2) Cos[x - t]^2 + 1;
pics = Table[Plot[u[x, t], {x, -10, 10}, PlotRange -> {0, 1.5}, 
  PlotStyle -> {Red, Thickness[0.005]}], {t, 0, 2 Pi, 2 Pi/50}];

Now, Export:

Export["anim.gif", pics]

enter image description here

$\endgroup$
  • $\begingroup$ Dear Mark McClure, Thanks. I figured that out just a few minutes ago and was going to add it as a comment when I saw your answer:-). Thank you for your help. $\endgroup$ – Radz Aug 28 '14 at 15:05
  • $\begingroup$ No problem - I'm glad you figured it out. $\endgroup$ – Mark McClure Aug 28 '14 at 15:06

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