Re: Clear subscripted variables
- To: mathgroup at smc.vnet.net
- Subject: [mg58292] Re: Clear subscripted variables
- From: David Bailey <dave at Remove_Thisdbailey.co.uk>
- Date: Sun, 26 Jun 2005 01:33:54 -0400 (EDT)
- References: <d9ispk$cpd$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Mukhtar Bekkali wrote:
> Here is the code (x\_i stands for x subscript i):
>
> Table[{Print[x\_i = i]; Clear[x]; Remove[x]; Unset[x]; Print[x\_i]},
> {i, 1, 2}]
>
> I expected that x\_i is cleared at the end of the loop but it isn't
>
> If I insert Clear[Subscript] in the loop then it is cleared, but not
> desirable since it clears all variables with subscripts.
>
> What command shall I use to clear specific subscripted variables?
>
> Mukhtar Bekkali
>
Hi,
Try this:
Table[a\_i =. , {i, 1, 10}]
This is equivalent to the use of Unset[a\_i]
David Bailey
http://www.dbaileyconsultancy.co.uk