# Binding a variable to an unbound variable [closed]

I'm trying to do something like the following: (minimal example, f2 unbound)

case = 2;
f = Switch[case, 1, f1, 2, f2]
Plot[{f2^2}, {f, 0, 10}]


but the plot comes out blank. The second line outputs f2 so it does recognize that f=f2. Any recommendations?

• What exactly are you trying to do? Something along the lines of f1 = Sin[x]; f2 = x^2; case = 2; f = Switch[case, 1, f1, 2, f2]; Plot[{f^2}, {x, 0, 10}]? If so, you should check your variables and assignments. f is (presumably) a function, but you'd want Plot to iterate over a variable in that function (x in my example), not over f. – Graumagier Nov 1 '15 at 9:42
• Plot has the HoldAll attribute, so the second argument will not be evaluated (or any of the arguments for that matter). Try Plot[{f2^2}, Evaluate@{f, 0, 10}]. – sebhofer Nov 1 '15 at 10:10
• @sebhofer your Evaluate@ trick worked perfectly and is simple, thanks! – Hanmyo Nov 4 '15 at 8:03