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 am writing a notebook where I have to configure several curves (using locators in manipulates), to not repeat code I would like to write a function that wraps a manipulate and returning the manipulated value, that is doing something like:

a = MyManipFunc[];
Dynamic[a + 3]

Where The first line would display a manipulate and the second would dynamically update to reflect the value currently set. The best I have managed is (Reduced to bare minimals):

MyManipFunc[] := Module[{tt = 16},
  Print[
    Manipulate[
      tt = t; t,
      {t, 0, 10}]
  ];
  tt
]

But does not do as I want since a is not updated despite including Dynamic. Any pointers would be appreciated!

share|improve this question
    
Maybe I'm missing the point but tt is changing it's value while using Manipulator. Switch tt to Dynamic@tt at the end of the code to see that. –  Kuba Jul 3 '13 at 20:38
1  
Would the much simpler expression Column@{Manipulate[a = t, {t, 0, 10}], Dynamic[a + 3]} be what you are looking for? –  m_goldberg Jul 3 '13 at 20:44
    
Is this what you finally want do to: MyPlotFunc[some code ... MyManipFunc[] ... some code], so you would obtain the dynamic value from inside your plot function? Intuitively, I would swap that, using MyManipFunc as a wrapper to any plot function and doing something like: MyManipFunc[MyPlotFunc, {dynamic vars}]. MyManipFunc will then pass the dynamic values as arguments to MyPlotFunc. That is also pretty straight-forward to realize. –  Theo Tiger Jul 4 '13 at 14:21
    
Hi, thank you all for your comments, despite it not beeing precisely what I was looking for I can make it workshops by inverting the logic as suggested by Theo. –  Vskrap Jul 6 '13 at 18:06
add comment

Your Answer

 
discard

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

Browse other questions tagged or ask your own question.