# How to assign (and retrieve) variables with subscripts? [duplicate]

I like to give subscripts to my variable names when the variables are related. I.e.,

Subscript[r, i] = 3


3

A problem arises when I later assign r to a value and want to use Subscript[r,i] again.

r = 6


6

Subscript[r, i]


Subscript[6, i]

Is there any way for me to get the value I assigned to Subscript[r,i]? Is this the wrong way to use Mathematica?

• #5 here is relevant – ssch Oct 15 '13 at 13:58
• very similar (duplicate?) – gpap Oct 15 '13 at 14:00
• Please read the documentation for Notations and Symbolize – Mike Honeychurch Oct 15 '13 at 21:20
• This pitfall discussion is also relevant. – m_goldberg Oct 16 '13 at 7:56
• Thanks all for your comments. I'll try to avoid doing this in the future. Unfortunately, this is why I use Mathematica. If I can't do this, then I'll most likely stick with another language. – jlconlin Oct 16 '13 at 14:32