http://www.mathworks.com/matlabcentral/newsreader/view_thread/248365
MATLAB Central Newsreader  what is command for repeat?
Feed for thread: what is command for repeat?
enus
©19942014 by MathWorks, Inc.
webmaster@mathworks.com
MATLAB Central Newsreader
http://blogs.law.harvard.edu/tech/rss
60
MathWorks
http://www.mathworks.com/images/membrane_icon.gif

Sun, 05 Apr 2009 06:32:03 +0000
what is command for repeat?
http://www.mathworks.com/matlabcentral/newsreader/view_thread/248365#640383
apple
i'm doing the homework about finding the largest number and i found the key word is used the flow chart. so, i tried to create the command for repeat.. however it show error undefined the word REPEAT. so what is the command for repeat? <br>
and this are the flow chart related with my program<br>
<br>
<a href="http://www.edrawsoft.com/images/examples/Sum%20of%20first%2050%20natural%20numbers.png">http://www.edrawsoft.com/images/examples/Sum%20of%20first%2050%20natural%20numbers.png</a>

Sun, 05 Apr 2009 06:47:03 +0000
Re: what is command for repeat?
http://www.mathworks.com/matlabcentral/newsreader/view_thread/248365#640385
Matt Fig
At the Matlab prompt, type:<br>
<br>
doc for<br>
<br>
Read everything, and when you are done click the link at the bottom of the page to read about the While loop. Also you should read about the If statement.

Sun, 05 Apr 2009 07:47:36 +0000
Re: what is command for repeat?
http://www.mathworks.com/matlabcentral/newsreader/view_thread/248365#640393
Roger Stafford
"apple " <Quixotic04@yahoo.com> wrote in message <gr9j93$bu7$1@fred.mathworks.com>...<br>
> i'm doing the homework about finding the largest number and i found the key word is used the flow chart. so, i tried to create the command for repeat.. however it show error undefined the word REPEAT. so what is the command for repeat? <br>
> ........<br>
<br>
Unfortunately there is no "repeatuntil" command in the matlab language. I have often wished there were. In my opinion Mathworks made an error in judgement in omitting it from their repertoire.<br>
<br>
The closest thing to it is the "whileloop" and you can always simulate the "repeatuntil" action using the "while" construction and the appropriate boolean(s), but sometimes that can be a nuisance. Here's an example:<br>
<br>
% The nonexistant "repeat" command<br>
c = 0;<br>
repeat<br>
x = rand;<br>
y = rand;<br>
z = rand;<br>
c = c+1;<br>
until x+y+z > 2.999;<br>
<br>
% Simulation with "whileloop"<br>
c = 0;<br>
b = true;<br>
while b<br>
x = rand;<br>
y = rand;<br>
z = rand;<br>
c = c+1;<br>
b = x+y+z > 2.999;<br>
end<br>
<br>
Roger Stafford

Sun, 05 Apr 2009 11:24:01 +0000
Re: what is command for repeat?
http://www.mathworks.com/matlabcentral/newsreader/view_thread/248365#640409
Roger Stafford
"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <gr9nmo$h5u$1@fred.mathworks.com>...<br>
> .......<br>
> % The nonexistant "repeat" command<br>
> c = 0;<br>
> repeat<br>
> x = rand;<br>
> y = rand;<br>
> z = rand;<br>
> c = c+1;<br>
> until x+y+z > 2.999;<br>
> <br>
> % Simulation with "whileloop"<br>
> c = 0;<br>
> b = true;<br>
> while b<br>
> x = rand;<br>
> y = rand;<br>
> z = rand;<br>
> c = c+1;<br>
> b = x+y+z > 2.999;<br>
> end<br>
> ......<br>
<br>
Whoops! I got that whileloop logic backwards. Sorry about that. To be equivalent to the "repeat" construct, it should be:<br>
<br>
...<br>
b = true;<br>
while b<br>
....<br>
b = x+y+z <= 2.999<br>
end<br>
<br>
(It should require quite a few passes through the loop before that boolean becomes false, somewhere in the neighborhood of six billion.)<br>
<br>
Roger Stafford

Sun, 05 Apr 2009 11:46:02 +0000
Re: what is command for repeat?
http://www.mathworks.com/matlabcentral/newsreader/view_thread/248365#640410
Bruno Luong
"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <gr9nmo$h5u$1@fred.mathworks.com>...<br>
> "apple " <Quixotic04@yahoo.com> wrote in message <gr9j93$bu7$1@fred.mathworks.com>...<br>
> > i'm doing the homework about finding the largest number and i found the key word is used the flow chart. so, i tried to create the command for repeat.. however it show error undefined the word REPEAT. so what is the command for repeat? <br>
> > ........<br>
> <br>
> Unfortunately there is no "repeatuntil" command in the matlab language. I have often wished there were. In my opinion Mathworks made an error in judgement in omitting it from their repertoire.<br>
> <br>
> The closest thing to it is the "whileloop" and you can always simulate the "repeatuntil" action using the "while" construction and the appropriate boolean(s), but sometimes that can be a nuisance. Here's an example:<br>
> <br>
> % The nonexistant "repeat" command<br>
> c = 0;<br>
> repeat<br>
> x = rand;<br>
> y = rand;<br>
> z = rand;<br>
> c = c+1;<br>
> until x+y+z > 2.999;<br>
> <br>
<br>
May be this syntax of WHILE "looks" closer REPEAT:<br>
<br>
while true<br>
x = rand;<br>
y = rand;<br>
z = rand;<br>
c = c+1;<br>
if x+y+z > 2.999<br>
break;<br>
end<br>
end<br>
<br>
Bruno