A good way of presenting your work is to use animations. This is true when you have an analytical model where you need to explore the behavior of the solution under a change of certain control parameters. There's an easy way of doing this using Mathematica. Here is a sample code in mathematica
(* Define function to be animated *)The animation will look like this
f[x_, L_] = Cos[L*x];
(* Create a table of plots *)
theTable = Table[ Plot[{f[x, L]}, {x, -4, 4}], {L, 1, 10}];
(* Export this table into an animated GIF - Replace gif with swf to export as a flash swf file*)
Export["C:\\TestAnimation.gif", theTable, ImageSize->350];
Voila!
Of course, you need to set the parameters that are relevant to your animation. You can also animate several functions. In this case, include the functions in the Plot section of the table. For example
(* Define functions to be animated *)The animation in this case looks like this
f[x_, L_] = Cos[L*x];
g[x_, L_] = Sin[L*x];
(* Create a table of plots *)
theTable = Table[ Plot[{f[x, L], g[x, L]}, {x, -4, 4}], {L, 1, 10}];
(* Export this table into an animated GIF - Replace gif with swf to export as a flash swf file*)
Export["C:\\TestAnimationCombo.gif", theTable, ImageSize->350];
Download Mathematica notebook [right click / save as]
Cite as:
Saad, T. "Animations in Mathematica".
Weblog entry from
Please Make A Note.
http://pleasemakeanote.blogspot.com/2008/05/create-mathematica-swf-animation.html
Thanks, this was very helpful for an mathematical animation I was working on.
ReplyDeleteBrilliant! I spent the last two days trying to export animations from Mathematica 7, to no avail. Your simple no-nonsense examples are a breath of fresh air!
ReplyDeleteThank you Dave! I am glad that this post was helpful for you. I greatly appreciate your feedback!
ReplyDeleteI followed your instructions, but my animated gif file stops after one loop through the plots. I am using Mathematica 5.2 on Linux and Firefox 3.0.7 to view the gif file. How do I put the animation in an "infinite repeat" loop?
ReplyDeleteThanks for your comment. Try adding the following option to the Export command:
ReplyDeleteAnimationRepetitions->Infinity
I hope that works.
Interesting, thanks so much for sharing, this can be very useful if you know how to use it.
ReplyDeleteI was looking for this information, thanks for put in this easy way, I mean in a easy way to understand it jajaja, well until the next time.
ReplyDeletethanks I wasn't just able to do it as I was using manipulate and simply replaced it by Table ans it worked great.
ReplyDelete