Re: Subscripted Variables
- To: mathgroup at smc.vnet.net
- Subject: [mg16469] Re: [mg16364] Subscripted Variables
- From: Carl Woll <carlw at u.washington.edu>
- Date: Sat, 13 Mar 1999 02:22:05 -0500
- Organization: Physics Department, U of Washington
- References: <199903110716.CAA12243@smc.vnet.net.>
- Sender: owner-wri-mathgroup at wolfram.com
Mitchell, The problem you are having is that Mathematica stores the definitions for subscripts as downvalues for the head Subscript. I have three different possible solutions for you. In the following I have pasted in stuff from Mathematica using InputForm and OutputForm so there won't be any ambiguity. 1. Whenever you give a value to a subscript, make it an upvalue for your variable. For example, In[38]:= x /: Subscript[x, c] = 1; In[39]:= Subscript[x,c] Out[39]= 1 In[40]:= Clear[x] Subscript[x,c] Out[41]= x c 2. Define a function which removes DownValues for Subscript associated with a variable. In[51]:= ClearSubscript[c_]:=( DownValues[Subscript]=Cases[DownValues[Subscript],a_/;a[[1,1,1]]=!=c];) In[52]:= Subscript[x,c]=1; Subscript[x,c] Out[53]= 1 In[54]:= ClearSubscript[x] Subscript[x,c] Out[55]= x c 3. Use the Symbolize command from the Notation package. My preferences go as follows. If I will make extensive use of subscripts, I prefer option 2. If I make occasional use of subscripts, I prefer option 1. I personally don't like the Symbolize package. Why don't you try these out, and see what you like best. -- Carl Woll Dept of Physics U of Washington Mitchell Kaplan wrote: > I'd like to use subscripts to make my notation more readable. I'm running > Windows98 and used the template to add a subscript to a variable -- such as > "x" with a subscript of "c". > > Everything works fine until I try to clear the values. Normally I use the > following statement to clear my values: > Clear["Global`*"]. This doesn't seem to work on my subscripted variables. > > I then tried using them as local variables in a Block -- it didn't seem to > recognize them as valid symbols. Once I assign one of them, I can reset it > by setting it equal to "." . However, if I have a statement which sets all > of them to "." I get error messages regarding ones that haven't yet been > used. > > This is more of an inconvenience than a crisis, but I would really > appreciate any help anyone could offer. > > Thanks, > > Mitchell
- References:
- Subscripted Variables
- From: "Mitchell Kaplan" <qmak@pipeline.com>
- Subscripted Variables