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?
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 wantPlot
to iterate over a variable in that function (x
in my example), not overf
. $\endgroup$ – Graumagier Nov 1 '15 at 9:42Plot
has theHoldAll
attribute, so the second argument will not be evaluated (or any of the arguments for that matter). TryPlot[{f2^2}, Evaluate@{f, 0, 10}]
. $\endgroup$ – sebhofer Nov 1 '15 at 10:10Evaluate@
trick worked perfectly and is simple, thanks! $\endgroup$ – Hanmyo Nov 4 '15 at 8:03