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

Issue with Synchronization between Manipulate and functions called by Manipulate with Graphics[]

0 views
Skip to first unread message

Nasser Abbasi

unread,
Jul 14, 2007, 2:48:01 AM7/14/07
to
(Mathematica 6.0, Windows XP, OLD PC)

Manipulate[expr,{n,1,10}] is supposed to evaluate expr for each value
of 'n'.

There seems to be a synchronization problem between Manipulate[] and
completing evaluation of expr, when there is a Graphics inside expr.

I have a simple example below, where expr is a function, which
displays 'n'.

---- CODE -----------------

process[a_] := Graphics[ {Text[StringJoin["a=", ToString[a]]]},
ImageSize -> {40} ]

Manipulate[ process[a], {a, 1, 10, 1} ]

---- END CODE -----------------------

If you run the above, and click on 'play' and look at the display
inside the Graphics window, you will see that not every integer is
being printed. i.e. NOT each 'n' is being displayed.

Some values of 'n' are skipped. What is being displayed is something
like 2,4,6... or 1,2,3,5,6,... instead of 1,2,3,4,5,.... i.e. some numbers
do NOT get displayed, while Manipulate itself is of course is
incrementing 'n' correctly. This ofcourse might depend on speed of
the computer itself and other factors, but on my slow PC, I see this
is clearly happening.

I think this happens because Manipulate is calling expr before the
previous Graphics[] which displays the text is fully flushed out to
display within the function expr.

Hence, expr returns back, and Manipulate now calls it with n+1 value,
before the previous n value is yet displayed, and so n+1 overwrites
earlier 'n' in some internal Graphics buffer, and what I see is n+1
and 'n' is missing.

I need a way to make sure Graphics[] is completed inside expr before
I return back from the function, back to Manipulate, to prevent this
problem.

To confirm this, when I 'slow' down Manipulate using the 'slow'
control, now I see that each number is being displayed ok. So this
clearly is telling me there is a buffer overrun problem.

I need to study the documentation more, I just started using
Manipulate, but I noticed this problem.

Do you think I am interpreting this ok, or am I doing something silly
elsewhere?

thank you
Nasser


Jens-Peer Kuska

unread,
Jul 15, 2007, 1:14:50 AM7/15/07
to
Hi,

Manipulate[Dynamic@ process[a], {a, 1, 10, 1}]

may help ...

Regards
Jens

0 new messages