MathGroup Archive 2008

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

Search the Archive

Re: Converting a string to a variable name

  • To: mathgroup at smc.vnet.net
  • Subject: [mg90331] Re: Converting a string to a variable name
  • From: Bill Rowe <readnews at sbcglobal.net>
  • Date: Sun, 6 Jul 2008 07:18:41 -0400 (EDT)

On 7/5/08 at 4:52 AM, aaronfude at gmail.com (Aaron Fude) wrote:

>Is it possible to create a variable whose name is contained in
>another variable or a string, something along the lines of

>Table[ a="Var"<>ToString[i]; Variable[a] = i^2, {i, 1, 10}]

>and end up with variables Var1, ..., Var10?

Use ToExpression to do this. For example,

In[1]:= ToExpression["var" <> ToString@#] & /@ Range[10]

Out[1]= {var1,var2,var3,var4,var5,var6,var7,var8,var9,var10}


  • Prev by Date: Parallelising NDSolve
  • Next by Date: Re: lie symmetry package
  • Previous by thread: Re: Converting a string to a variable name
  • Next by thread: Re: Converting a string to a variable name