Matlab approximation of 0 for small numbers
6 次查看(过去 30 天)
显示 更早的评论
Hi,
I'm attempting to check for error convergence, but I'm entering an infinite loop, and I believe the culprit is Matlab approximating a small number as 0. These numbers are used in the calculation of my error,
xx = 1 - ((ff*ddff)/(2*dff*dff))
bb = ((ff*ddff)/(2*dff*dff)) % for display and debugging purposes only
But for some early iterations I get stuck in an infite loop and the outputs are
xx =
1
bb =
-1.2633e-08
This in turn affects the error calculation (decreasing the tolerance of my error fixes the situation but this is not desireable). Clearly the theoretical answer of xx is not exactly 1 (as the output format suggests, shouldn't it display 1.000?). Would matlab be approximating bb = 0 in this case? Any way to change the approximation tolerance? Any help is appreciated.
Mark
0 个评论
采纳的回答
更多回答(1 个)
另请参阅
类别
在 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!