Re: How to get values from Manipulate
- To: mathgroup at smc.vnet.net
- Subject: [mg98968] Re: How to get values from Manipulate
- From: Albert Retey <awnl at gmx-topmail.de>
- Date: Wed, 22 Apr 2009 06:35:56 -0400 (EDT)
- References: <gsmmrg$cu7$1@smc.vnet.net>
Hi,
> just a simple question related to Manipulate[] - is there a way how to access the values set by slider in Manipulate?
>
> For example, I have the following code:
>
> m = Manipulate[
> ListLinePlot[{
> data,
> {{xmin, 0}, {xmin, 100}}
> }],
> {xmin, 1, 10}
> ]
>
> and after the user sets a value 'xmin', I would like to read it out. How?
It really depends on what you want to achieve, but the most simple
solution is to just set a global variable within the Manipulate:
Manipulate[
parameter1 = n;
Plot[Sin[n x], {x, 0, 2 \[Pi]}, Frame -> True, ImageSize -> 400],
{n, 0, 1},
]
whenever you now access parameter1 it will have the value that is shown
in Manipulate. To refer to your other question, you can also make e.g. a
modal dialog which returns that value like so:
newvalue = DialogInput[DynamicModule[{parameter1 = 0},
Column[{
Manipulate[
parameter1 = n;
Plot[Sin[n x], {x, 0, 2 \[Pi]}, Frame -> True, ImageSize -> 400]
,
{n, 0, 1},
AppearanceElements -> None
],
Button["OK", DialogReturn[parameter1]]
}]]
]
hth,
albert