MathGroup Archive 2009

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

Search the Archive

Re: Re: Re: Manipulate: How to

  • To: mathgroup at smc.vnet.net
  • Subject: [mg103090] Re: [mg103071] Re: [mg103064] Re: [mg103049] Manipulate: How to
  • From: Bob Hanlon <hanlonr at cox.net>
  • Date: Tue, 8 Sep 2009 05:54:56 -0400 (EDT)
  • Reply-to: hanlonr at cox.net

On the help page for Manipulate under More information it states that the following forms by default yield particular forms of controls:

{u, {u1, u2, ...}}     setter bar for few elements; popup menu for more

{u, {u1 -> lab1, u2 -> lab2, ...}}     setter bar or popup menu with labels for elements

Labels can be specified for one or more or all of the values. Without a specified label the value is also the label.

Values used as labels:

{{choice, 1, "Select Range Choice"}, {1, 2}}

Specified labels:

{{choice, 1, "Select Range Choice"},
 {1 -> "Low Range, 0-10", 2 -> "High Range, 10-20"}}

One specified label (first) and one using the value as a label (second):

{{choice, 1, "Select Range Choice"},
 {1 -> "Low Range, 0-10", "High Range, 10-20"}}

In this last case you specified a string value as both the value and the default label. Any value for this second choice could be used in this specific Manipulate since the If statements only test for the first value (1).


Bob Hanlon

---- Syd Geraghty <sydgeraghty at me.com> wrote: 

=============
Hi Bob et al,

Two inputs.

1)


Based on Bob's input I have modified his code to make it a little bit  
easier to see what is happening.


Manipulate[
  Manipulate[
   Column[{"x     = " Text[x], "xmin  = " Text[xmin],
     "xmax  = " Text[xmax], "xstep = " Text[xstep]}], {{x,
     If[choice == 1, 5, 15], "x ="},
    xmin = If[choice == 1, 0, 10],
    xmax = If[choice == 1, 10, 20],
    xstep = If[choice == 1, .1, .5]}
                          ](*1st nested Manipulate*),
     {{choice, 1, "Select Range Choice"}, {1 -> "Low Range, 0-10",
    2 -> "High Range, 10-20"},
   ControlType -> SetterBar}
                         ](* Outer Manipulate*)


I am still struggling to understand the syntax of the SetterBar  
structure.

Bob used:      {{choice, 1, "select choice"}, {1 -> "UP", -1 ->  
"DOWN"},  ControlType -> SetterBar}

I was somewhat surprised that for the second choice of button that the  
value  "-1"  worked OK but I could not use != 1 (not equal 1).


Syntax::sntxb : Expression cannot begin with " != 1 -> High range,  
10-20".


I also note that:

{{choice, 1, "Select Range Choice"}, {1 -> "Low Range, 0-10", 2 ->  
"High Range, 10-20"},  ControlType -> SetterBar}

and

{{choice, 1, "Select Range Choice"}, {1 -> "Low Range, 0-10", "High  
Range, 10-20"},  ControlType -> SetterBar}

both work fine!

So what is the way to understand the relation between "choice" and the  
SetterBar list?

The Manipulate documentation does not help me in trying to understand  
this point, perhaps someone could explain it.

2)

In running some tests above I had a lot of Dynamic evaluations and  
several times I had to abort Mathematica because the kernel was "not  
responding to Dynamic".

Has any one recently upgraded to Snow Leopard and seen the same thing?  
I never ran in to this before on my Mac with any other version of OS X.

Thanks ... Syd




Syd Geraghty B.Sc, M.Sc.

sydgeraghty at mac.com

Mathematica 7.0.1 for Mac OS X x86 (64 - bit) (18th February 2009)
MacOS X V 10.6 Snow LeopardMacBook Pro 2.33 GHz Intel Core 2 Duo  2GB  
RAM



On Sep 6, 2009, at 4:38 AM, Bob Hanlon wrote:

>
> You can nest Manipulate
>
> Manipulate[
> Manipulate[
>  Text[x],
>  {{x, 1, "x ="},
>   If[choice == 1, 0, 1],
>   If[choice == 1, 10, 20],
>   0.1}],
> {{choice, 1, "select choice"},
>  {1 -> "UP", -1 -> "DOWN"},
>  ControlType -> SetterBar}]
>
>
> Bob Hanlon
>
> ---- Nasser Abbasi <nma at 12000.org> wrote:
>
> =============
> Hello.
>
> This is Mathematica 7.
>
> I have Manipulate control (a slider) which I want to dynamically  
> adjust its
> initial value and maximum value based on what one selects as a  
> choice from
> another control (SetterBar) and also change the position of the  
> slider (i.e.
> the current value of the slider) based on the choice selected.
>
> The following code below seems to work initially. Using 'If'  
> statement, I
> check the current choice, and set the initial and maximum value of the
> slider.
>
> The problem though is that the current value of the slider (i.e. the  
> current
> position of the slider) remains at whatever value it was before the  
> user
> changed the choice, and this could result in the current value of  
> the slider
> being larger than the maximum being set for the new choice.
>
> What I want is the following: When the user selects a new choice  
> (from the
> SetterBar), I want to reset the current position on the slider as  
> well the
> initial and the maximum value.
>
> Here is the code to help explain:
>
> Manipulate[Text[x],
>
>  {{x, 1, "x="}, If[choice == 1, 0, 1],    If[choice == 1, 10, 20],  
> 0.1},
>
>  {{choice, 1, "select choice"},  {1 -> "UP", -1 -> "DOWN"},  
> ControlType ->
> SetterBar}
>
> ]
>
> So, when one selects UP, I change the initial slider value to start  
> at 1
> instead of at 0, and made the maximum slider to be 10 instead of 20.
> However, the value of 'x' itself could be at say 12 at this time  
> (becuase
> the user was moving it), and so it overflows now.
>
> How can I also update 'x' to start at some specific value each time  
> the user
> changes the choice from UP to DOWN or from DOWN to UP?  Putting  
> another If
> statement does NOT work:
>
> Manipulate[Text[x],
>
> {{x, If[choice == 1, 3, 5], "x="},   If[choice == 1, 0, 1], If 
> [choice == 1,
> 10, 20], 0.1},
>
>  {{choice, 1, "select choice"}, {1 -> "UP", -1 -> "DOWN"},
>   ControlType -> SetterBar}
>
> ]
>
> I know I need to use Dynamic[] somewhere, but I not sure where and  
> how to
> force current slider value to rest each time the setterbar is  
> clicked. I
> need some sort of action associated with SetterBar which I can use  
> each time
> its value changes, but SetterBar has no such option.
>
> any help is appreciated.
>
> --Nasser
>



  • Prev by Date: Re: An arithmetic puzzle, equality of numbers.
  • Next by Date: Re: An arithmetic puzzle, equality of numbers.
  • Previous by thread: Re: Re: Re: Manipulate: How to
  • Next by thread: Re: Re: Re: Manipulate: How to