# How to control Manipulate speed

I want to ask about how can we control Manipulate function so that it is not incrementing the step until the expression is calculated.

I have the following simple code:

data = RandomReal[1, {100, 10}];
data2 = ConstantArray["Emp", {100, 10}];
Manipulate[

data2[[1 + IntegerPart[i/10.00000001], i - IntegerPart[i/10.00000001]*10]] =
data[[1 + IntegerPart[i/10.00000001], i - IntegerPart[i/10.00000001]*10]];

data2 // TableForm, {i, 1, 1000, 1}]


If you see when you click the "PlayButton", the Manipulate jumps the step in non-sequential odder so that it is not calculating the expressions in sequential odder.

I want to ask if there is any way to control the play action of Manipulate so that it is not moving to i + 1 until it is calculated the expressions at i. • With default speed it's just not doing steps one by one. You can check with Alt key pressed, then Slider is slower and will update each value. What is the goal at the end? Because I feel like the job you want is not the one for Manipulate. – Kuba May 1 '14 at 18:38

I'm not sure if it is possible to do what you want in exactly the way you want. The Manipulator runs independently of the updates of the Manipulate body. So its value keeps changing while the Manipulate body is being recalculated. You would need to get the Manipulator to execute FinishDynamic after each update to i. I don't know if that is possible. Probably not.

Here's a workaround:

data = RandomReal[1, {100, 10}];
data2 = ConstantArray["Emp", {100, 10}];
Manipulate[

If[running && i <= 1000, i = i + 1];

data2[[1 + IntegerPart[i/10.00000001], i - IntegerPart[i/10.00000001]*10]] =
data[[1 + IntegerPart[i/10.00000001], i - IntegerPart[i/10.00000001]*10]];
data2 // TableForm,

{i, 1, 1000, 1},
{{running, False}, {True, False}}]


Click on the running check box and it will update data2 one entry at a time. • @Kuba AnimationRate -> 1 works as long as each update of the Manipulate body takes less than a second. It would nice if there were a setting such as AnimationRate -> Manipulate and it would wait until the Manipulate has updated. – Michael E2 May 1 '14 at 21:05
• Yes, sorry I've deleted my comment while there were some web glitches, haven't seen your reply :) – Kuba May 1 '14 at 21:09
• @Kuba I've updated my comment to fill in the missing option... :) – Michael E2 May 1 '14 at 21:10
• And yes, this option should be available :) – Kuba May 1 '14 at 21:11
• Thank you guys, it would be great if an option is adde to manipulate function in the coming mathematica 10 so that updating process of the body can be adjusted. but this way works very fine and it help a lot. thank you Kuba and Michael. – Algohi May 3 '14 at 4:03

The example below shows the effects of forcing a unitary step size in the manipulator in the application you created. The table is filled as expected but there is an uncomfortable lag in the manipulator. I created this example to support the following statements. I think that Manipulator really doesn't need a new option but that programmers need to adjust their code to use it the way it has been designed. In general, controls that use Dynamic assume that the evaluation of Dynamic is |"instantaneous", and in this case it is also assumed that the first priority is that the cursor and the slider should move together minimizing any lag or lack of synchronization.

DynamicModule[{data = RandomReal[1, {100, 10}],
data2 = ConstantArray["Emp", {100, 10}], i = 0, manipulatorValue = 0}
,
Column[{
Manipulator[Dynamic[i,
(
i = If[# > manipulatorValue, i + 1, i - 1];
data2[[1 + IntegerPart[i/10.00000001],
i - IntegerPart[i/10.00000001]*10]] =
data[[1 + IntegerPart[i/10.00000001],
i - IntegerPart[i/10.00000001]*10]];
manipulatorValue = #;
) &
]
, {0, 100, 1}
]
,
Pane[
Dynamic[
Refresh[
data2 // TableForm
, TrackedSymbols -> {i}
]
, SynchronousUpdating -> Automatic
]
, ImageSize -> {Automatic, 200}, Scrollbars -> Automatic
]
}
]
]


The example below exemplifies what I mean by adjusting the code to use Manipulator as it was designed.

DynamicModule[{data = RandomReal[1, 1000],
data2 = ConstantArray["Emp", 1000], i = 0,}
,
Column[{
Manipulator[Dynamic[i,
(
i = #;
data2[[1 ;; i]] = data[[1 ;; i]];
) &
]
, {0, 1000, 1}
]
,
Pane[
Dynamic[
Refresh[
TableForm@Partition[data2, 10]
, TrackedSymbols -> {i}
]
, SynchronousUpdating -> Automatic
]
, ImageSize -> {Automatic, 200}, Scrollbars -> Automatic
]
}
]
]