# How to define a variable with a subscripted part

I have looked around, but found no real answer for this. I generally use Mathematica for thermodynamics and electromechanical equations and for this, to keep a good overview, i got used to defining variables with a subscripted explanation like so:

Subscript[Z,motor] := Quantity[60, "Ohms"]


Mathematica will mess this notation form up when used in calculations.

I would still prefer to do my definitions this way, but have come to realize that it may well be to impractical in Mathematica?

• Yes. It is mostly discouraged to use Subscripted and Superscripted variables. A striking reason is that your definition is not stored in the variable Z (try ??Z to see that), but within Subscript! (Try ??Subscript.) For example, resetting Z does not reset the subscripted Zs. This is diametral to what you would expect from Subscript (but it is perfect Mathematica logic). – Henrik Schumacher Nov 6 '17 at 18:39
• Then what would be a recommended format for defining variables, in a way that clarifies the variables purpose? – Jamie Nov 7 '17 at 12:27
• What about Zmotor or ZMotor? Well, many people would tell you to avoid variable names starting with a capital letter (knowing that single letters such as C, D, E, I, K and a few others would not work, this still would rarely collide with built-in symbols), so zmotor or zMotor might be better. Never ever use Z_motor and similar things as an underscore has a built-in meaning (it defines patterns). – Henrik Schumacher Nov 7 '17 at 14:58
• And how would that work if I have multiple variables with number indexing? Like if i have the P1 effect of a motor and i install another motor. Then i would normally call them by Subscribt[P1,1] and Subscribt[P1,2]. If i write those in the format you tell, then it would be p(which is the variable name for pressure)11 and p12. Which would give me no chance of keeping a sensible overview. – Jamie Nov 10 '17 at 11:30
• Put them into arrays. – Henrik Schumacher Nov 10 '17 at 11:44