MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Show doesn't work inside Do loop ?

  • To: mathgroup at smc.vnet.net
  • Subject: [mg101926] Re: [mg101906] Show doesn't work inside Do loop ?
  • From: "David Park" <djmpark at comcast.net>
  • Date: Thu, 23 Jul 2009 03:55:32 -0400 (EDT)
  • References: <32390795.1248259308283.JavaMail.root@n11>

A Do loop never generates any output on its own. Print generates the output,
so add a Print header to the Show statement.

Do[Print["i =", i];
 Fig = Plot[Sin[i*x], {x, -5, 5}];
 Print@Show[Fig], {i, 1, 5}]

Notice that that produces 10 separate Output cells.

It is possible to generate the entire display in a single Output cell, and
have more specific control on the overall format, using Table, Column and
Row commands.

Table[
  Column[
   {Row[{"i = ", i}],
    Plot[Sin[i x], {x, -5, 5}]
    }](* Column *),
  {i, 1, 5}] // Column


David Park
djmpark at comcast.net
http://home.comcast.net/~djmpark/  



From: ibmichuco at hotmail.com [mailto:ibmichuco at hotmail.com] 


Hi,

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.

Thanks,

Michuco




  • Prev by Date: Re: Show doesn't work inside Do loop ?
  • Next by Date: Re: patterns
  • Previous by thread: Re: Show doesn't work inside Do loop ?
  • Next by thread: Re: Show doesn't work inside Do loop ?