2

How do I make a variable $k_{1x}$ where the $x$ is just a label to denote the magnitude along the x-axis and not an actual defined variable x in the code?

Similarly, if I wanted to make $E_x$ or $E_{0x}$ for electric field notations, not only can I not use a variable subscript, the $E$ is replaced by Exp.

Edmund
  • 42,267
  • 3
  • 51
  • 143

1 Answers1

2

Does this do what you need?

ClearAll[kx, k, x]
Format[kx[n_]] := Subscript[k, n, x]
kx[1]
kx[1] = 5
kx[1]

If for some reason you actually need variables with subscripts, see How to create symbol whose name has subscript?

Alan
  • 13,686
  • 19
  • 38
  • Would the x be integrated if I did Integral(k_1x) here? – Nisha Mariam Johnson Sep 24 '16 at 21:29
  • @NishaMariamJohnson I'm confused. In your qeustion, you said you wanted x as a label, not as a variable. Are you now saying you want it to be a (bound) variable in an integrand? – Alan Sep 25 '16 at 01:12