Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

weird Manipulate/Animate

5 views
Skip to first unread message

mire

unread,
May 25, 2007, 7:23:54 AM5/25/07
to
does anyone know why this code works

graph = Table[Plot[Sin[x + i], {x, 0, \[Pi]}], {i, 3}];
ListAnimate[graph]

and this one doesn't

n = 3; graph = Table[0, {n}];
For[i = 1, i <= n, i++,
graph[[i]] = Show[Plot[Sin[x + i], {x, 0, \[Pi]}]]];
ListAnimate[Evaluate[graph]]

?
I am puzzled!


Lev Bishop

unread,
May 26, 2007, 4:26:25 AM5/26/07
to

Heh. Because even WRI can't remember mathematica's bizarre and
confusing scoping rules?
A more succinct example of the problem:
i=1;
ListAnimate[{"a","b","c"}]

Ie, the problem is that ListAnimate gets tripped up by Global`i.
Somewhere in the definition of ListAnimate is this:
Manipulate`Dump`res=With[{Manipulate`Dump`i=Symbol[i],....] ,
which almost makes it look as though this is on purpose, but I can't see why.

Anyway, for now, just don't use the variable i in any situation where
you might use ListAnimate.

Lev

0 new messages