From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Matlab Code-Problem with loop.
Date: Sat, 4 Jun 2011 00:14:05 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 9
Message-ID: <isbtcd$9nr$>
References: <isbkc3$i9r$>
Reply-To: <HIDDEN>
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: 1307146445 9979 (4 Jun 2011 00:14:05 GMT)
NNTP-Posting-Date: Sat, 4 Jun 2011 00:14:05 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: comp.soft-sys.matlab:730129

"Casi " <> wrote in message <isbkc3$i9r$>...
> So, I'm trying to run a random code that should randomize the results with a variable number of particles. As it stands, the code will keep running until the time runs out but will not stop when it goes above the allocated number of particles. I tried putting that in the while statement, but it doesn't seem to be working. The code is below:
> .........
>     while ((a+b)<=(a0+b0) && t<=tf)
> .........
- - - - - - - - - - -
  I see nothing to stop the while loop except t>tf.  The sum a+b will never change from a constant a0+b0.  I see nothing that would detect if either a or b become negative, so the while loop could easily continue on with a negative number of particles in either a or b.  Is that what you observed?  If you want it to stop when either becomes negative, you should test for that.

Roger Stafford