MathGroup Archive 2009

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

Search the Archive

variable number of controls in manipulate

  • To: mathgroup at smc.vnet.net
  • Subject: [mg105512] variable number of controls in manipulate
  • From: Greg Colbourn <gcolbourn at hotmail.com>
  • Date: Sun, 6 Dec 2009 01:30:22 -0500 (EST)

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"}, {"Globavg", 
"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: Newbie Qn: Change Directory
  • Next by Date: Re: How to combine Dynamic graphics in Show?
  • Previous by thread: Resizing of main window after closing help
  • Next by thread: Re: variable number of controls in manipulate