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!