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) **************************************************