Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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.

enter image description here

share|improve this question
    
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 at 18:38

2 Answers 2

up vote 2 down vote accepted

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.

Mathematica graphics

share|improve this answer
    
@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 at 21:05
    
Yes, sorry I've deleted my comment while there were some web glitches, haven't seen your reply :) –  Kuba May 1 at 21:09
    
@Kuba I've updated my comment to fill in the missing option... :) –  Michael E2 May 1 at 21:10
    
And yes, this option should be available :) –  Kuba May 1 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 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
    ]
   }
  ]
 ]
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.