Re: Converting a string to a variable name
- To: mathgroup at smc.vnet.net
- Subject: [mg90338] Re: [mg90318] Converting a string to a variable name
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Sun, 6 Jul 2008 07:20:00 -0400 (EDT)
- Reply-to: hanlonr at cox.net
ToExpression[Table[ "var" <> ToString[i] <> "=" <> ToString[i^2], {i, 10}]]; Names["var*"] {var1,var10,var2,var3,var4,var5,var6,var7,var8,var9} ToExpression[%] {1,100,4,9,16,25,36,49,64,81} var5 25 Bob Hanlon ---- Aaron Fude <aaronfude at gmail.com> wrote: ============= Hi, 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? Thanks! Aaorn