MathGroup Archive 2003

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

Search the Archive

Stopping a For loop

  • To: mathgroup at smc.vnet.net
  • Subject: [mg43083] Stopping a For loop
  • From: "Miguel Cruz" <pyro_gest at hotmail.com>
  • Date: Mon, 11 Aug 2003 02:16:00 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Good day All,

I am trying to do a For (or Do) loop and having it stooping when a 
certain result is achieved.

My For loop is:

For[s=0,s<10,s++,
a=y6[s]-sin[Pi/2-y3[s]]*y1[s]*y1[s]/rhop*y2[s]) /.solution;
Print[s,a]
]

where solution is the solution for a system of six ODEs.

I am trying to break the For loop when a is larger than h:

testFOR[h_]:=
For[s=0, s<10; If[a-h>0, Break[]] ,s++,
a=y6[s]-sin[Pi/2-y3[s]]*y1[s]*y1[s]/rhop*y2[s]) /.solution;
Print[s,a]
]

My problem is that the loop never breaks unless in the If condition I 
put the iterator s.

Thank you very much for your help.
Cheers,
Miguel

**************************************************
Please note new email address!
**************************************************
Miguel Cruz
460 "The Bullpen" Science Complex
College of Forestry and Conservation
University of Montana
Missoula, MT 59812

Phone: (406) 329 4748 (@ FiSL)
Fax:   (406) 329 4825 (@ FiSL)
**************************************************


  • Prev by Date: Re: Mathematica 5.0: small change in fundamental behaviour.
  • Next by Date: RE: ListPlot3D of a Square Array
  • Previous by thread: Re: Mathematica 5.0: small change in fundamental behavior.
  • Next by thread: Re: Stopping a For loop