there is a way that if clause it is execute
조회 수: 1 (최근 30일)
이전 댓글 표시
Here it is a piece of code:
x = rand;
if x < 1E-6
do-something
end
if I execute this piece of block in loop, the program never execute if clause because x is always bigger. how can I enter in that block?
댓글 수: 0
채택된 답변
per isakson
2012년 9월 20일
편집: per isakson
2012년 9월 20일
Try this:
for ii = 1 : 1e7
x = rand;
if x < 1E-6
disp( 'do-something' )
end
end
do-something
do-something
do-something
do-something
do-something
do-something
do-something
Thus, in this case it was executed seven times. (R2012a,64bit,Win7)
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Clusters and Clouds에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!