4

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.

Radz
  • 185
  • 1
  • 8

1 Answers1

5

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

Mark McClure
  • 32,469
  • 3
  • 103
  • 161