Re: Question

*To*: mathgroup at smc.vnet.net*Subject*: [mg110238] Re: Question*From*: Erik Max Francis <max at alcyone.com>*Date*: Thu, 10 Jun 2010 08:06:37 -0400 (EDT)*References*: <huntc8$bka$1@smc.vnet.net>

David Lengacher wrote: > How can you create a set of variables: x1 to xn using the Table, or some > similar function? I need a large list of variables to use in a linear > program and so far have to type them out manually." You can stitch them together with ToString and Symbol: In[11]:= Table[Symbol["x" <> ToString[i]], {i, 1, 5}] Out[11]= {x1, x2, x3, x4, x5} But better yet, there's no real reason to do this in the first place. Mathematica's fully symbolic, even with unknown functions, so you really shouldn't need to make them into individual symbols in the first place: In[12]:= Table[x[i], {i, 1, 5}] Out[12]= {x[1], x[2], x[3], x[4], x[5]} In[13]:= x[1] = 2; x[2] = 3; x[1] + x[2] Out[15]= 5 -- Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/ San Jose, CA, USA && 37 18 N 121 57 W && AIM/Y!M/Skype erikmaxfrancis I wonder if this grief will ever let me go -- Sade