MathGroup Archive 2009

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

Search the Archive

Re: variable number of controls in manipulate

  • To: mathgroup at smc.vnet.net
  • Subject: [mg105554] Re: variable number of controls in manipulate
  • From: Greg Colbourn <gcolbourn at hotmail.com>
  • Date: Tue, 8 Dec 2009 06:45:34 -0500 (EST)
  • References: <200912070659.BAA12913@smc.vnet.net>

Hi Bob,
Thanks for the reply, but that's not exactly what I was after. I don't want a list of the vartitles, I want a number that I can use to pick out data. I've managed to get the number (see my original post below), but I can't do anything with it. In the example below, corresponding to the varvalues, there is an ensemble of 48 datasets. I can get the number corresponding to the correct dataset, but I want to use the number to pick out the data to plot it. Using my code at the bottom, you can see that as soon as you assign the number to a symbol (k), it can no longer be used as a number!
Greg

> Date: Mon, 7 Dec 2009 01:59:31 -0500
> From: hanlonr at cox.net
> Subject: [mg105531] Re: variable number of controls in manipulate
> To: mathgroup at smc.vnet.net
>
>
> Perhaps this will help.
>
> vartitles = {
>    "Emissions",
>    "Weathering scheme",
>    "Ca weath feedback",
>    "Si weath feedback"};
>
> varvalues = {
>    {"None", "1000GtC", "3000GtC", "5000GtC"},
>    {"Globavg", "GKWM", "GEM_CO2"},
>    {"On", "Off"},
>    {"On", "Off"}};
>
> Module[{n = 1},
>  Manipulate[
>   Evaluate[
>    Table[v[n], {n, Length[varvalues]}]],
>   Evaluate[
>    Sequence @@ (
>      Inner[{{v[n++], #2[[1]], #1}, #2} &,
>       vartitles, varvalues, List])]]]
>
> Although I recommend that you enter and store the titles and values together to keep them linked. For example,
>
> varData = {
>    {"Emissions",
>     {"None", "1000GtC", "3000GtC", "5000GtC"}},
>    {"Weathering scheme",
>     {"Globavg", "GKWM", "GEM_CO2"}},
>    {"Ca weath feedback",
>     {"On", "Off"}},
>      {"Si weath feedback",
>     {"On", "Off"}}};
>
> Module[{n = 1},
>  Manipulate[
>   Evaluate[
>    Table[v[n], {n, Length[varvalues]}]],
>   Evaluate[
>    Sequence @@ (
>      Inner[{{v[n++], #2[[1]], #1}, #2} &,
>       Sequence @@
>        Transpose[varData], List])]]]
>
>
> Bob Hanlon
>
> ---- Greg Colbourn <gcolbourn at hotmail.com> wrote:
>
> =============
> Hi.
>
> I'm running ensembles of models and want to look at the results in
> Mathematica in an automated way. Part of this revolves around
> automatically generating lists of buttons corresponding to variables
> using Manipulate - the number of variables to loop over is itself
> variable(!).
>
> I can work out automatically a number corresponding to an individual
> ensemble member depending on which variables are chosen:
>
> (* edit these to contain more or less variables, with more or less
> values for \
> each variable: *)
> vartitles = {"emissions", "Weathering scheme", "Ca weath feedbcak"=
,
>    "Si weath feedback"};
> varvalues = {{"none", "1000GtC", "3000GtC", "5000GtC"}, {"Globa=
vg",
> "GKWM",
>     "GEM_CO2"}, {"on", "off"}, {"on", "off"}};
>
> nvars = Table[Length[varvalues[[i]]], {i, Length[varvalues]}];
> nvar = Length[nvars];
>
> Format[v[n_Integer]] := "v" <> ToString[n];
> list = Array[v, nvar];
> varmultipliers =
>   Append[Reverse[
>     Table[Product[nvars[[n]], {n, nvar, nvar - m, -1}], {m, 0=
, nvar -
> 2}]], 1];
>
> (* this generates ensemble number corresponding to variable selection:
> *)
> Manipulate[
>    (*k=*)Evaluate[
>     Total[(Evaluate[Table[Evaluate[list][[i]], {i, nvar}]] - 1)*
>        varmultipliers] + 1], 
>    ##] &@(Sequence @@
>    Table[{{list[[i]], 1, vartitles[[i]]},
>      Table[j -> varvalues[[i, j]], {j, nvars[[i]]}]}, {i, nvar}=
])
>
> However, when I want to do anything with this number (removing the
> commented out "k="), it becomes a list of symbols and no longer a
> number, despite me using Evaluate. Ideally, I want to be able to use=

> this number (k) as an index to pick out data from arrays.
>
> What do I need to do?
>
> Greg Colbourn
>
>
 		 	   		 


  • Prev by Date: Re: How to combine Dynamic graphics
  • Next by Date: Re: Special Input Characters' Reference Table
  • Previous by thread: Re: Re: variable number of controls in manipulate
  • Next by thread: Re: variable number of controls in manipulate