Re: Symbol function, a question

• To: mathgroup at smc.vnet.net
• Subject: [mg90522] Re: Symbol function, a question
• From: "David Park" <djmpark at comcast.net>
• Date: Fri, 11 Jul 2008 02:06:47 -0400 (EDT)
• References: <g54om5\$f1i\$1@smc.vnet.net>

```I'm not quite certain what your objective here is.

x95 = 100;

Notice what happens if you Trace the evaluation of the Symbol expression.

Symbol["x" <> ToString[95]] // Trace
{{{ToString[95], 95}, x<>95, x95}, Symbol[x95], x95, 100}

So the statement:

Symbol["x" <> ToString[95]] = 20

evaluates to:

100 = 20    which Mathematica baulks at.

So if you want to reset the value of the symbol why not just write:

x95 = 20

If you want x95 to change its value in other expressions when you assign a
new value to it use:

Dynamic[x95]

Evaluate that, and then evaluate in turn:

x95 = 100;

x95 = 20

and see what happens to the Dynamic[x95] output.

--
David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/

"tung tran" <tunganhtr at yahoo.fr> wrote in message
news:g54om5\$f1i\$1 at smc.vnet.net...
> Hi everybody, I have a question needing your help.
> Firstly, I create a variable
> x95 = 100
> Now, I want to change the value of my variable x95 to 20 ,
> so I want to use some procedure like :
>
> Symbol["x" <> ToString[95]] = 20
> my idea is to make Mathematica write the term "x95" automatically for
> me but when I use the Symbol function in this case, it gives me
> automatically 100 and I don' t know how to call only x95.
> Thank you if someone can give me a suggestion.
>
>
> Tung
>

```

• Prev by Date: Re: Almost symbolic computations (?)
• Next by Date: Re: Import/Export Problem
• Previous by thread: Re: Symbol function, a question
• Next by thread: Re: Symbol function, a question