6
$\begingroup$

This works:

Manipulate[Plot[2*x + 3*y, {x, 3, 4}], {y, 3, 4}]

But this doesn't

f=2*x + 3*y
Manipulate[Plot[f, {x, 3, 4}], {y, 3, 4}]

My "f" is a painful long expression so I'd rather be able to get the latter method to work than work with the former.

$\endgroup$
9
$\begingroup$

Manipulate has to 'see' the that f depends on y, so define it as follows:

f[x_, y_] = 2*x + 3*y
Manipulate[Plot[f[x, y], {x, 3, 4}], {y, 3, 4}]

Mathematica graphics

By the way, this is mentioned in the "Possible Issues" section of the Manipulatedoc page.

$\endgroup$
  • $\begingroup$ Thanks a lot!. That saved me a ton of time. I usually look at "More Information" and all the options and examples but I don't always look at "possible issues". I will keep it in mind to check it every time from now on. Thx. $\endgroup$ – Amatya Aug 28 '12 at 20:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.