Re: Show doesn't work inside Do loop ?
- To: mathgroup at smc.vnet.net
- Subject: [mg101930] Re: Show doesn't work inside Do loop ?
- From: Bill Rowe <readnews at sbcglobal.net>
- Date: Thu, 23 Jul 2009 03:56:15 -0400 (EDT)
On 7/22/09 at 6:22 AM, ibmichuco at hotmail.com wrote:
>Is there a way to use Show inside a Do loop? For example, the
>following doesn't work:
>Do[
>Print["i =",i]; Fig = Plot[Sin[i*x], {x, -5, 5}]; Show[Fig] , {i, 1,
>5}]
>I would like to print different info at each step of the loop,
>therefore saving all Fig in a Table or Array doesn't help me.
I really don't know why Show doesn't work in the manner you were
expecting. But simply changing Show to Print looks like it does
what you want. i.e.,
Do[Print["i =", i];
Fig = Plot[Sin[i*x], {x, -5, 5}];
Print[Fig], {i, 1, 5}]
I also don't understand why you think Table won't do. On my machine
Table[Print["i =", n]; Print@Plot[Sin[n x], {x, -5, 5}], {n, 5}];
Produces exactly the same output as the Do loop with Print and
seems to execute faster.