Path: news.mathworks.com!not-for-mail
From: "Dave Robinson" <dave.robinson@somewhere.biz>
Newsgroups: comp.soft-sys.matlab
Subject: Re: do while
Date: Thu, 15 May 2008 14:31:02 +0000 (UTC)
Organization: STFC Rutherford Appleton Laboratory
Lines: 55
Message-ID: <g0hhf6$k5n$1@fred.mathworks.com>
References: <g0gt2m$h3q$1@fred.mathworks.com> <16944196.1210857274898.JavaMail.jakarta@nitrogen.mathforum.org>
Reply-To: "Dave Robinson" <dave.robinson@somewhere.biz>
NNTP-Posting-Host: webapp-02-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1210861862 20663 172.30.248.37 (15 May 2008 14:31:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 15 May 2008 14:31:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 968489
Xref: news.mathworks.com comp.soft-sys.matlab:468606


CandyGirl <Rasha@dqnetwork.com> wrote in message 
<16944196.1210857274898.JavaMail.jakarta@nitrogen.mathforum.
org>...
> Yes there is,
> 
> 
> A=5
> B=2
> 
> while(A > B)
> C = (A+B)/2
> B=B+1
> end
> 
> hope that helped

The 'C' family has both 
while(test)
{

}

and 

do
{

}while(test)

they are different. With the while loop, if test is false 
the code in the curlies is bypassed, if it is true it is 
continuously looped until it becomes false, With the do - 
while construct the code in the curlies is always executed 
at least once, then the value of test controls whether the 
code is reexecuted, the two constructs are slightly 
different animals.

There is probably a much better way of doing it, but 
perhaps the following abomination might give you the 
functionality you need.

while(true) %Loop forever
    Your code
    if(!test)
      break;
    endif
endwhile

Regards

Dave Robinson