Path: news.mathworks.com!not-for-mail
From: "Jos " <DELjos@jasenDEL.nl>
Newsgroups: comp.soft-sys.matlab
Subject: Re: do while
Date: Thu, 15 May 2008 14:39:03 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 21
Message-ID: <g0hhu7$m2u$1@fred.mathworks.com>
References: <g0gt2m$h3q$1@fred.mathworks.com>
Reply-To: "Jos " <DELjos@jasenDEL.nl>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1210862343 22622 172.30.248.38 (15 May 2008 14:39:03 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 15 May 2008 14:39:03 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 870065
Xref: news.mathworks.com comp.soft-sys.matlab:468608


"Deo " <spliers@hotmail.com> wrote in message
<g0gt2m$h3q$1@fred.mathworks.com>...
> is there a matlab command equivalent to the C do while

There is a subtle difference between a "do-while" loop and
"while" loop:
do-while executes the loop at least once, whereas while may
skip the loop altogether

A work-around:

% an infinite for-loop
for i=1:Inf,
   % ... code ...
   if ~condition, 
     break ; % break out of the for-loop
   end
end

hth
Jos