Path: news.mathworks.com!not-for-mail
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$1@newscl01ah.mathworks.com>
References: <isbkc3$i9r$1@newscl01ah.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: www-01-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: newscl01ah.mathworks.com 1307146445 9979 172.30.248.46 (4 Jun 2011 00:14:05 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sat, 4 Jun 2011 00:14:05 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1187260
Xref: news.mathworks.com comp.soft-sys.matlab:730129

"Casi " <beatlesschic@gmail.com> wrote in message <isbkc3$i9r$1@newscl01ah.mathworks.com>...
> 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