chop doesn't chop very small numbers
6 次查看(过去 30 天)
显示 更早的评论
I have a small number, say 1e-14, and I want to chop it to three decimals. In this case, it should give 0. Yet:
>> chop(1e-14, 3) ans = 1.0000e-14
What is going on?
3 个评论
Star Strider
2018-10-1
The only reference I can find on an InterWeb search is the Wolfram function Chop—Wolfram Language Documentation (link).
I cannot find any documentation for a function of that exact name in MATLAB in a similar search.
采纳的回答
Steven Lord
2018-10-1
I believe chop is an old function from Control System Toolbox. I recommend using round instead. The default behavior of round is to round to N decimals but you can also use it to round to N significant digits (which is what chop(X, N) does.)
>> x = 1e-14;
>> round(x, 3)
ans =
0
>> round(x, 3, 'significant')
ans =
1.0000e-14
0 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!