Mathematica: two animations, one slider

In summary, the conversation discusses using Manipulate in Mathematica to create animations and potential issues with the code. The main problem is with the size of the animation frames and the use of Manipulate trying to create an extra frame. The conversation also mentions the use of a table called Final and the potential for errors in the code.
  • #1
MartinV
69
0
Hello everyone.

I have two animations in Mathematica, each with 187 frames. I would like to put one in a corner of the other and for them to share a slider so they both respond to it simultaneously.

Martin
 
Physics news on Phys.org
  • #2
Try something like this:
Manipulate[
Plot[Cos[\[Omega] t], {t, -\[Pi], \[Pi]},
Epilog ->
Inset[Plot[Sin[\[Omega] t], {t, -\[Pi], \[Pi]},
ImageSize -> Small], {Right, Bottom}, {Right, Bottom},
Background -> Opacity[.7, White]]], {\[Omega], -3, 3}]
 
  • #3
I've got an interesting problem with Manipulate. A few of the animation frames are Large while most of them are Medium. I explicitly said I want them Medium but they are still Large:

Manipulate[
Block[{spl =
ListLinePlot[Final, PlotRange -> {{-3, 3}, {1, 20}},
ImageSize -> Medium]},
Show[spl,
Graphics[{Red, PointSize[.02],
Point[{Final[[j, 1]], Final[[j, 2]]}]}], PlotLabel -> j]], {j, 1,
M, 1}]

Edit: weird that if I use PlotRange -> {{-1,1},{0,30}}, all frames are Medium. Why does this happen?
 
  • #4
Now I get another problem. Using the same code as before, I create a Manipulate animation. In a 100-frame animation Mathematica tries to create the 101st. It's always like this. When a graph is formed, I get warnings that 101st frame doesn't exist, even though the counter in Manipulate command only goes to 100. When I move the slider away from 101, the warnings disappear and then the slider has the specified range. Only when I form it, it tries to show me more than possible.
 
  • #5
I tried to run the code in post 3, but it is not self contained.

I have also had some difficulties in the past using Manipulate. What version of Mathematica are you using?
 
  • #6
I'm using Mathematica 7.

The code in post #3 uses the Final table, which is 187*2. M is the length, in this case 187. First row of Final is a set of numbers going from -10 to 10; the second row are numbers between 1 and 30.

I think if you just make a few numbers and then put M as the length of that array then the code should work.
 

1. What is Mathematica?

Mathematica is a software program used for mathematical computation, data analysis, and visualization. It is commonly used in scientific research, engineering, and education.

2. How can I create two animations in Mathematica?

To create two animations in Mathematica, you can use the Animate function and specify two different variables for each animation. For example, Animate[graphic1, {var1, range1}] and Animate[graphic2, {var2, range2}] will create two separate animations with different variables var1 and var2 and ranges range1 and range2.

3. Can I control the speed of the animations?

Yes, you can control the speed of the animations by using the AnimationRate option in the Animate function. You can specify the number of frames per second you want the animation to run at, for example, AnimationRate -> 10 will play the animation at 10 frames per second.

4. How do I add a slider to my animations in Mathematica?

To add a slider to your animations, you can use the Manipulate function. Inside the Manipulate function, you can specify the variables and ranges for your animations, and use the ControlType option to add a slider for one or both of the variables. For example, Manipulate[graphic1, {var1, range1}, ControlType -> Slider] will add a slider for the variable var1 in your animation.

5. Can I save my animations as a video or GIF?

Yes, you can save your animations in various formats such as video or GIF in Mathematica. You can use the Export function and specify the desired format, for example, Export["myanimation.mp4", animation] will save your animation as an MP4 video file.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
415
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
571
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
7K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
13
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
21
Views
5K
  • Computing and Technology
Replies
11
Views
663
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
Back
Top