how to write a while-loop for a function
1 次查看(过去 30 天)
显示 更早的评论
lim x-> inf (1 + 1/x)^x how to write a while-loop that repeats it self until the value of the subsequent numbers are less than 10^(-6)
0 个评论
回答(1 个)
Doug Hull
2012-10-10
flagMetTolerance = false
while ~flagMetTolerance
doMath
flagMetTolerance = (error <= tolerance)
end
2 个评论
Jan
2012-10-10
@Martin: Doug's program does the following: It is a while-loop, which calls the operation "doMath" repeatedly until a certain error value (the difference of subsequent elements in your case) is below the limit "tolerance".
I'm sure you will find out more details, if you are trying to use Matlab.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Matrices and Arrays 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!