MathGroup Archive 2010

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

Search the Archive

Re: loop for with plot

  • To: mathgroup at
  • Subject: [mg110043] Re: loop for with plot
  • From: Murray Eisenberg <murray at>
  • Date: Sun, 30 May 2010 23:44:53 -0400 (EDT)

This is a commonly-asked question (although most folks who ask usually 
have the same problem with Do rather than For).  The key is what the 
documentation says about For:

   Unless an explicit Return is used, the value returned by For is Null.

To get the body of the For to produce output for each value of the 
counter, just include a Print -- just like the very first Basic Example 
in the docs show:

        Print[Plot[{2*R3*Sin[ArcCos[x/R3]]*e3},{x,-2R3,2 R3}]]

(pretty-printed for syntactical clarity).

On 5/30/2010 6:47 AM, maria giovanna dainotti wrote:
> Dear Mathgroup,
> when I am using the loop for with plot is not working.
> here is the example
> R1=1.029
> R2=3
> R3=6
> e1=27
> e2=0
> e3=2.5
> For[e3=0,e3<4,e3++,Plot[{2*R3*Sin[ArcCos[x/R3]]*e3}, {x, -2R3,2 R3}]]
> How can I sort out the problem?
> Best regards
> Maria

Murray Eisenberg                     murray at
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305

  • Prev by Date: Re: Lists: how to?
  • Next by Date: Re: Basic normal and t table questions
  • Previous by thread: Re: loop for with plot
  • Next by thread: Re: loop for with plot