MathGroup Archive 2010

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

Search the Archive

Re: Question

  • To: mathgroup at
  • Subject: [mg110261] Re: Question
  • From: David Bailey <dave at>
  • Date: Thu, 10 Jun 2010 08:10:48 -0400 (EDT)
  • References: <huntc8$bka$>

On 09/06/10 12:19, 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.
> David

The simple answer is:

myvars=Table[ToExpression["XX" <> ToString[k]], {k, 1, 10}]

However, working with created variable names like that can be quite 
tricky because either they evaluate when you don't want them to, or you 
end up assigning to an expression such as myvars[[5]], rather than the 
variable itself.

For that reason, you may want to present a bit more of your problem so 
as to get a complete solution.

David Bailey

  • Follow-Ups:
    • Re: Question
      • From: David Carraher <>
  • Prev by Date: Answer
  • Next by Date: Re: Question
  • Previous by thread: Re: Question
  • Next by thread: Re: Question