# Subscripted variables give errors in Module expression [closed]

I have following problem. I want the R not to calculate before the integration but substitute later as a function of z. My Mathematica codes look like:
Codes like big, (sorry) but most of them are just the parameters.

yCal[z_] :=
Module[{â„ = 1.05*10^-27, e = 4.8*10^-10, c = 3*10^10,
Subscript[Ïµ, âˆž] = 1.1431, Ï‰d =
1.3202*10^16, Î³ = 1.0805*10^14,
Subscript[Î“, 1] = 4.4642*10^14,
Subscript[Î“, 2] = 2.3555*10^15,
Subscript[Ï•, 1] = -1.2371, Subscript[Ï•, 2] = -1.0968,
Subscript[A, 1] = 0.26698, Subscript[A, 2] = 3.0834,
Subscript[Ïµ, d] = 1, Î» = 630*10^-7,
L = 1000*10^-7,
ko = (2 Pi)/(630*10^-7), Ï‰ = (2.0*Ï€*3*10^10)/(
630*10^-7), R, Subscript[n, eff], Subscript[Î±, 1],
Subscript[Î±, 2], C1, C2, A, Ï, Ez,
Subscript[Ïµ, m], MyFun, Pl},
Subscript[n, eff] =
Sqrt[4/(ko^2*((L – z)*Tan[2.2 Degree])^2) (
Subscript[Ïµ, d]/Subscript[Ïµ, m])/
ProductLog[
Exp[0.577]*Subscript[Ïµ, d]/Subscript[Ïµ, m]] +
Subscript[Ïµ, d]];
Subscript[Ïµ, m] =
Subscript[Ïµ, âˆž] – (Ï‰d^2*Ï‰^2)/(\
Ï‰^4 + Î³^2*Ï‰^2) + \!\(
\*UnderoverscriptBox[\(âˆ‘\), \(p = 1\), \(2\)]\(
\*SubscriptBox[\(A\), \(p\)]\ \
\*FractionBox[\(Cos[
\*SubscriptBox[\(Ï•\), \(p\)]]\ *\((
\*SubscriptBox[\(Î“\), \(p\)]*Sin[
\*SubscriptBox[\(Ï•\), \(p\)]]\), \(
\*SuperscriptBox[
\*SuperscriptBox[\(Ï‰\), \(2\)] +
\*SuperscriptBox[
SubscriptBox[\(Î“\), \(p\)], \(2\)]\)] +
\*FractionBox[\(Cos[
\*SubscriptBox[\(Ï•\), \(p\)]]\ *\((
\*SubscriptBox[\(Î“\), \(p\)]\ \ *Sin[
\*SubscriptBox[\(Ï•\), \(p\)]]\), \(
\*SuperscriptBox[
\*SuperscriptBox[\(Ï‰\), \(2\)] +
\*SuperscriptBox[
SubscriptBox[\(Î“\), \(p\)], \(2\)]\)])\)\)\);
Subscript[Î±, 1] =
Sqrt[Subscript[n, eff]^2 – Subscript[Ïµ, m]];
Subscript[Î±, 2] =
Sqrt[Subscript[n, eff]^2 – Subscript[Ïµ, d]];
C1 = (Abs[BesselK[1, ko*Subscript[Î±, 1]*R]])^2 Integrate[
Abs[BesselI[1,
ko*Subscript[Î±, 1] *Ï]]^2*Ï, {Ï, 0, R}];
C2 = (Abs[BesselI[1, ko*Subscript[Î±, 1]*R]])^2 Integrate[
Abs[BesselK[1,
ko*Subscript[Î±, 1] *Ï]]^2*Ï, {Ï,
R, âˆž}];
With [{A1 = C1, A2 = C2, Ind = Subscript[n, eff]},
A = (Subscript[n, eff]*c)/2*(
Subscript[Ïµ, m]*Subscript[Ïµ,
d]*(Abs[BesselK[1, ko*Subscript[Î±, 1]*R]])^2)/(
Subscript[Ïµ, d]*Hold@A1 +
Subscript[Ïµ, m]*Hold@A2)];
ReleaseHold[A /. R = (L – z)*Tan[2.2 Degree]] ;
MyFun = Integrate[ko*Subscript[n, eff], z];
Ez = (A*Subscript[Î±, 1])/Subscript[Ïµ, m]
BesselI[0, ko*Subscript[Î±, 1] *Ï] Cos[MyFun]]

I want to calculate Ez.
There is an error about “Local variable specification.” even though there are no variables kept within the Module{}.

=================

=================

1

=================

A minimum working example that reproduces your problem is:

Module[{Subscript[Ïµ, âˆž] = 1.1431}, Subscript[Ïµ, âˆž]]

Module::lvset: Local variable specification {Subscript[Ïµ, âˆž]=1.1431} contains Subscript[Ïµ, âˆž]=1.1431, which is an assignment to Subscript[Ïµ, âˆž]; only assignments to symbols are allowed. >>

The message is very clear. You simply can not use subscripted expressions as local variables in Module expression. The fix is to substitute valid identifiers for subscripted expressions.

Module[{Ïµâˆž = 1.1431}, Ïµâˆž]

1.1431