Re: loop for with plot

*To*: mathgroup at smc.vnet.net*Subject*: [mg110043] Re: loop for with plot*From*: Murray Eisenberg <murray at math.umass.edu>*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: For[e3=0,e3<4,e3++, 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 math.umass.edu 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