Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.soft-sys.math.mathematica > #13918
| From | Bob Hanlon <hanlonr357@gmail.com> |
|---|---|
| Newsgroups | comp.soft-sys.math.mathematica |
| Subject | Re: Manipulate and Initialization |
| Date | 2013-03-24 08:16 +0000 |
| Message-ID | <kimcog$pr5$1@smc.vnet.net> (permalink) |
| References | <20130323072431.19F0E6A0D@smc.vnet.net> |
| Organization | Time-Warner Telecom |
Use Dynamic
nn = 23;
Manipulate[n,
{n, 1, Dynamic[nn], 1, Appearance -> "Labeled"},
Initialization :>
(nn = RandomInteger[{5, 15}]; Print[nn])]
Bob Hanlon
On Sat, Mar 23, 2013 at 3:24 AM, Fred Simons <f.h.simons@tue.nl> wrote:
> I want to create a rather complicated Manipulate, in which I do not know
> the limits for the parameter beforehand; they depend on the result of an
> initialization. Here is a highly simplfied example:
>
> Clear[nn];
> Manipulate[n, {n,1,nn,1},
> Initialization:>(nn=RandomInteger[{5,15}];Print[nn])]
>
> This works fine. The slider can be used in the range from 1 to the
> printed value.
>
> However, when nn already has a value, the behaviour is different. When
> we execute
>
> nn=23;
> Manipulate[n, {n,1,nn,1},
> Initialization:>(nn=RandomInteger[{5,15}];Print[nn])]
>
> a value between 5 and 15 for nn is printed, but that value is not used
> in the result; the slider now runs from 1 to 23.
>
> So, whether nn has a value or not, just before the box structure is
> printed, the frontend asks the kernel to evaluate the initialization.
> But the returned value of nn is used in Manipulate only when nn did not
> have a value before. That embarasses me. Any explanation is highly
> apprectiated.
>
> Fred Simons
> Eindhoven University of Technology
>
Back to comp.soft-sys.math.mathematica | Previous | Next — Next in thread | Find similar | Unroll thread
Re: Manipulate and Initialization Bob Hanlon <hanlonr357@gmail.com> - 2013-03-24 08:16 +0000 Re: Manipulate and Initialization debguy <johnandsara2@cox.net> - 2013-04-02 07:25 +0000 Re: Manipulate and Initialization debguy <johnandsara2@cox.net> - 2013-04-03 07:22 +0000
csiph-web