5
$\begingroup$

This snippet

mm = m
Manipulate[{mm, Plot[mm x, {x, 0, 1}]}, {m, 0, 1}]

(m is not defined anywhere) produces a sadly fixed output, m remains symbolic.

This instead

mm = m
Manipulate[Evaluate@{mm, Plot[mm x, {x, 0, 1}]}, {m, 0, 1}]

makes the first element of the list be dynamically evaluated, but not the Plot, which remains empty because m remains symbolic. Lastly,

mm = m
Manipulate[{%, Plot[% x, {x, 0, 1}]}, {m, 0, 1}]

gets the correct thing, everything is evaluated dynamically. Why?

$\endgroup$
0

1 Answer 1

2
$\begingroup$

As I understand it... Manipulate-able variables are only evaluated when they are defined within Manipulate

mm = m
Manipulate[{%, Plot[% x, {x, 0, 1}]}, {m, 0, 1}]

is the same as writing,

Manipulate[{mm = m, Plot[mm x, {x, 0, 1}]}, {m, 0, 1}]

In your first two examples the variable m is undefined and remains that way (i.e. is not linked to the Manipulate variable m).

Is this an answer? Perhaps, not quite?...

It is interesting that Evaluate seems to force mm to link to the Manipulate-"m" but doesn't work for Plot... Also, if only Plot is evaluated, e.g.,

Manipulate[{mm, Evaluate[Plot[mm x, {x, 0, 1}]]}, {m, 0, 1}]

The output slider stops working, however, the graphic is now dynamically linked to the other sliders/outputs in the notebook... try it!

Weird.

$\endgroup$

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