Why there is no truncate function in Matlab?
61 次查看(过去 30 天)
显示 更早的评论
Hi,
I need to truncate values in a For loop and round() isn't working. I was just wondering why there is no truncate function yet?
0 个评论
采纳的回答
Image Analyst
2017-8-24
Because round sometimes rounds up - away from zero. I think you may want to use fix() instead of round(). It always rounds towards zero, in other words, truncates. See if that works for you and let me know.
2 个评论
Walter Roberson
2017-8-24
You should also know about floor(), which rounds towards negative infinity -- the maximum integer less than or equal to the input.
更多回答(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!