Re: subscripted local variables?
- To: mathgroup at smc.vnet.net
- Subject: [mg80726] Re: subscripted local variables?
- From: "Kevin J. McCann" <Kevin.McCann at umbc.edu>
- Date: Thu, 30 Aug 2007 02:33:56 -0400 (EDT)
- Organization: University of Maryland, Baltimore County
- References: <email@example.com>
I disagree with the previous comments on the use of subscripted symbols. I do it all the time. Here is what I suggest: Use the Notation package. Here is an example. You should note that in this example "xsub2" is turned into a symbol. This means that Mathematica puts a wrapper around it so that it treats "xsub2" as a symbol. Drop the stuff below into a new notebook, highlight the whole thing and do a Cntrl-Shift-N to see the notation, then execute. Kevin (*Here is a simple subscript, which works ok unless x is defined:*) Subscript[x, 2] FullForm[Subscript[x, 2]] x = 3; Subscript[x, 2] (*Ooops! Now undefine x:*) x =. (*and load the Notation package*) << Notation` (*Use the Symbolize button from the Notation Palette:*) Symbolize[\!\(\* TagBox[ SubscriptBox["x", "2"], "NotationTemplateTag"]\)] (*Now, note that the FullForm has changed:*) FullForm[Subscript[x, 2]] (*Mathematica has put a sort of wrapper around the whole thing so \ that it is treated as a single entity. Now let's define x again:*) x = 3; (*This time, however, everything works:*) Subscript[x, 2]