Re: Converting a string to a variable name
- To: mathgroup at smc.vnet.net
- Subject: [mg90348] Re: [mg90318] Converting a string to a variable name
- From: "Louis A. Talman" <talmanl at mscd.edu>
- Date: Sun, 6 Jul 2008 07:21:51 -0400 (EDT)
- References: <200807050852.EAA16862@smc.vnet.net>
On Jul 5, 2008, at 2:52 AM, 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? Var[1], Var[2], etc., is generally a better way to go, because it gives direct programmatic access to the variables. But if you really insist, try Table[a = "Var" <> ToString[i]; Evaluate[ToExpression[a]] = i^2, {i, 1, 10}] --Lou Talman Department of Mathematical and Computer Sciences Metropolitan State College of Denver <http://clem.mscd.edu/%7Etalmanl>
- References:
- Converting a string to a variable name
- From: Aaron Fude <aaronfude@gmail.com>
- Converting a string to a variable name