I want to simply set some parameters with sliders and click a button to start animation.

I know that I can manage this with Animate and Manipulate, but my animation is written like in this post, because I need to perform some calculations for stop condition.

So the point is that I want to start loop after setting parameters and clicking button. Is it achievable?


Ok, lets say that in the animation from linked post is some variable m

Do[p = Plot[m Cos[a x], {x, 0, 100}, Frame -> True, 
    FrameLabel -> {{None, None}, {x, 
  Style[Column[{"doing my own animation !", Cos[a x]}, 
    Alignment -> Center], 14]}}, GridLines -> Automatic];
If[a > 0.2, Break[]]; (*condition to stop*)
{a, 0.1, 1, .01}

I'd like to start this animation with button, and before that set m with slider.

  • $\begingroup$ Welcome to Mma.SE! With the setup from the link, try Dynamic[p] on one line and Button["start", Do[...]] on another or in another cell. Please note that in its present form, this question does not include enough details for people to give specific, accurate answers. Please include code that illustrates the problem -- feel free to copy the code from the linked post if it accurately illustrates your problem. Thanks! $\endgroup$ – Michael E2 Nov 22 '13 at 11:23
  • $\begingroup$ The problem is that after clicking button I get animation but last frame(already done). $\endgroup$ – tobix10 Nov 22 '13 at 11:31
  • $\begingroup$ Note that the goal, "to start loop after setting parameters and clicking button", can be achieved with Animate and Manipulate, too. $\endgroup$ – Michael E2 Nov 22 '13 at 13:15

To add a slider for setting m, try this:

Row[{Slider[Dynamic @ m, {0.1, 1, .01}], "  ", Dynamic @ m}]


topLbl = 
  Style[Column[{"Doing my own animation!", Dynamic @ m Cos[a x]}, Alignment -> Center], 14];

    p = Plot[m Cos[a x], {x, 0, 100},
      Frame -> True,
      FrameLabel -> {{None, None}, {x, topLbl}},
      GridLines -> Automatic];
    If[a > 0.2, Break[]];
    {a, 0.1, 1, .01}],
  Method -> "Queued"]




| improve this answer | |

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.