Struggled for a while on this problem and hopefully you can help... I have a mathematical expression that currently has a symbol where I used to have a function variable. How do I make the symbol back into a variable, so that my expression becomes a function again? My function became an expression when I saved it in a matrix, and so now I'm trying to make the different matrix elements back into functions after having constructed the matrix. Thanks in advance.
INCLUDING SOME CODE (my first time contributing on this website...)
Imagine a For loop sum (I've removed a substantial amount of code that's irrelevant for now)
Pstatesalpha[λ_]=0;
RankMatrix={};
elecdipole (*some vector of numbers*numbers delem*)
SumPstatesalpha[λ_, Alpharank_] (*a predefined function of λ, Alpharank*)
For[fsumFor[Alpharank = 1, fsumAlpharank <= 3, fsum++Alpharank++,(
For[jsum = 1, jsum <=Length[elecdipole], jsum++,(
Pstatesalpha[λ_] = (delem*a0)^2*SumPstatesalpha[λ,Alpharank] + Pstatesalpha[λ];
)]
AppendTo[RankMatrix, {Alpharank,Pstatesalpha[λ]}]
)]
Note that I've saved Pstatesalpha[λ]
as a function into RankMatrix
.
When I want to access (for instance)
RankMatrix[[1,2]]
Mathematica returns an expression that includes $\lambda$, but I can't use it as a function anymore.