Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2014

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: How to extract the numerical value of a dynamical variable?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg132559] Re: How to extract the numerical value of a dynamical variable?
  • From: Alexei Boulbitch <Alexei.Boulbitch at iee.lu>
  • Date: Fri, 11 Apr 2014 02:11:29 -0400 (EDT)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com
  • Delivered-to: l-mathgroup@wolfram.com
  • Delivered-to: mathgroup-outx@smc.vnet.net
  • Delivered-to: mathgroup-newsendx@smc.vnet.net

Hello
Could you please help me with following?

How can I get a real number (and not an expression) from a dynamic variable in "manipulate"? (my aim is to use that value in another function as "NonlinearModelFit"

Have a look at this example:

Lini = 1.95;
SumStart = 2750.; SumStop = 3100.;
{Manipulate [ Plot[ {Exp[-(2.97018 10^6 - 4481.87021 [Omega] + 2.53689 [Omega]^2 - 6.38403*10^-4 [Omega]^3 + 6.02659*10^-8 [Omega]^4) * L*10^-4]} , {[Omega], SumStart, SumStop}, PlotRange -> {0, 1}, GridLines -> Automatic, PlotStyle -> {{Red, Thickness[0.004]}}] , {{L, L0}, 0.0, 20, Appearance -> "Labeled"} (* =E9paisseur d'eau en microm=E8tres*) , LocalizeVariables -> False , Initialization -> {(L := Lini)} ] , {L0 = Dynamic[L] // N}; }

If I type (when the cursor's value is put on 13.1) :

In[1]= 5 + L0 + 0.1

I get:

Out[1]= 5.1 + 13.1

a mathematical expression!

I am looking for the corresponding real number 18.2 corresponding to the present value of the cursor!!!
How to get it?

Thanks for your help
Christian



Hi, Christian,

First there were errors in your code. I think to have cleaned it, but I am not sure that I did not remove something you had in mind to use.

To address your question, the answer is simple. You only need to make a global variable (below it is called "slider") and to assign it to the value of the local variable in question inside the Manipulate statement. Try this:

Lini = 1.95;
SumStart = 2750.;
SumStop = 3100.;
Manipulate[
 Clear[slider];
 Column[{
   Plot[Exp[-(2.97018 10^6 - 4481.87021 \[Omega] +
         2.53689 \[Omega]^2 - 6.38403*10^-4 \[Omega]^3 +
         6.02659*10^-8 \[Omega]^4)*L*10^-4], {\[Omega], SumStart,
     SumStop}, PlotRange -> {0, 1}, GridLines -> Automatic,
    PlotStyle -> {{Red, Thickness[0.004]}}, ImageSize -> 350],
   Button["Get the slider value", slider = L]
   }],

 {{L, Lini}, 0.0, 20, Appearance -> "Labeled"} ,
 LocalizeVariables -> False]

There is a global variable entitled "slider". There is also a button "Get the slider value" below the plot. As soon as you have your slider in the position to memorize it, press the button and the variable slider will have the value of L. You can type "slider" in another cell and evaluate it. It returns the memorized value.

Have fun, Alexei  

Alexei BOULBITCH, Dr., habil.
IEE S.A.
ZAE Weiergewan,
11, rue Edmond Reuter,
L-5326 Contern, LUXEMBOURG

Office phone :  +352-2454-2566
Office fax:       +352-2454-3566
mobile phone:  +49 151 52 40 66 44

e-mail: alexei.boulbitch at iee.lu






  • Prev by Date: Re: Very simple question
  • Next by Date: weird numbers
  • Previous by thread: Re: How to extract the numerical value of a dynamical variable?
  • Next by thread: Very simple question