Following True or False?
1 次查看(过去 30 天)
显示 更早的评论
Consider the following example. a and b are two random variables. The loop will exit if and only if a+b=1. Is it true or false?
a=rand;
b=rand;
while(a+b == 1)
a=rand;
b=rand;
end
采纳的回答
Walter Roberson
2012-8-27
While executes as long as the given condition is true, so the loop would only execute as long as the sum was 1.
Note: please take time to review the following: http://matlab.wikia.com/wiki/FAQ#Why_is_0.3_-_0.2_-_0.1_.28or_similar.29_not_equal_to_zero.3F
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Loops and Conditional Statements 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!