3
$\begingroup$

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]], Dynamic[cyA[change[g]]]}}] 
$\endgroup$
8
  • $\begingroup$ 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. $\endgroup$ Commented Mar 9, 2012 at 12:58
  • $\begingroup$ 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. $\endgroup$ Commented Mar 9, 2012 at 13:05
  • $\begingroup$ Aaah. I see. you want to access the value of cyL[x] outside of the Slider. Am I correct? $\endgroup$ Commented Mar 9, 2012 at 13:25
  • $\begingroup$ 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. $\endgroup$ Commented Mar 9, 2012 at 13:31
  • $\begingroup$ 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? $\endgroup$ Commented Mar 9, 2012 at 13:33

1 Answer 1

6
$\begingroup$

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

$\endgroup$
1
  • $\begingroup$ Thanks @FJRA! Works perfectly!! $\endgroup$ Commented Mar 13, 2012 at 18:00

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.