Take the 2-minute tour ×

In the code below the value displayed next to the slider may be correct, and should be the result of The value of x for cyL and the value of x for change at the slider position. Slider position 0 should provide the first values for x in these lines. Now if I evaluate xoutside of the function after moving the sliders, it only returns the slider position and not the value of x from the function. How can I get the variable to return the correct value for each slider? Thanks!

cyL[x_] := 
  58.770000000000046` - 3.557000000000158` x - 
   3.525333333333144` x^2 + 4.987999999999908` x^3 - 
   1.3386666666666487` x^4;

cyA[y_] := -35.13365403304179` - 0.009572400388682331` y + 
   0.08989310009715228` y^2 - 0.01687074829931251` y^3;

change[x_] := -0.17006802721089645` + 62.92517006802724` x - 
   6.802721088435384` x^2;

Column[{{Slider[Dynamic[x, Automatic]], 
   Dynamic[cyL[change[x]]]}, {Slider[Dynamic[g, Automatic]], 
share|improve this question
Works fine for me on OS X MMA 8.0.4. I get 59.2473 for the first number at slider position 0 and -35.1293 for the second. –  Timo Mar 9 '12 at 12:58
for the value of x or the displayed value of the slider? If I check the value of x at any slider position, I just get the slider position, I'm also on MM 8.04 OSX Try evaluating x outside of the function. That produces the slider position, I need the displayed value. –  R Hall Mar 9 '12 at 13:05
Aaah. I see. you want to access the value of cyL[x] outside of the Slider. Am I correct? –  Timo Mar 9 '12 at 13:25
Yes, well the result of x for cyL[change[x] yes thanks. I need to pass that number outside of the Dynamic to another function and then to a plot. –  R Hall Mar 9 '12 at 13:31
I meant the value displayed next to the slider. I'm sorry if I didn't understand your question correctly. Do you want to display x, change[x], cyL[x]. cyL[change[x]], or something else? Or do you want the access any (and which) of those outside of the slider? –  Timo Mar 9 '12 at 13:33
show 3 more comments

1 Answer

up vote 5 down vote accepted

After your last comment, maybe you should assing the value of cyL[change[x]] to another variable in the dynamic, and use it outside. Something like this:

enter image description here

share|improve this answer
Thanks @FRJA! Works perfectly!! –  R Hall Mar 9 '12 at 16:36
Thanks @FJRA! Works perfectly!! (and my apologies for misspelling) –  R Hall Mar 13 '12 at 18:00
add comment

Your Answer


