www.gusucode.com > matlab 案例源码 matlab代码程序 > matlab/ExitLoopBeforeWhileConditionIsFalseExample.m
%% Exit Loop Before Expression Is False % Sum a sequence of random numbers until the next random number is greater % than an upper limit. Then, exit the loop using a |break| statement. % Copyright 2015 The MathWorks, Inc. limit = 0.8; s = 0; while 1 tmp = rand; if tmp > limit break end s = s + tmp; end