Rounding numbers using a condition?
显示 更早的评论
I have an array of numbers ranging from 95 to 116. I would like to have the numbers closest to 99 in value be 99, the numbers closest to 104 in value be 104 and the number closest to 115 in value be 115. How could code this? Thanks for the help.
采纳的回答
更多回答(1 个)
Steven Lord
2016-4-28
1 个投票
Use interp1 with the 'nearest' method.
类别
在 帮助中心 和 File Exchange 中查找有关 Matrix Indexing 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!