Round to shortest integer
显示 更早的评论
In my program I access the data using a variable. This variable is calculated from lot of stuff. Now my problem is I am getting that variable value as 1.4464e+016(14464000000000000) and data is having only 32768 elements. Now i need to round this value to shortest integer to access the data.
You can assume this program like accessing array of elements using index, my question is how can I round this index value to the shortest integer using matlab functions.
回答(1 个)
Matt Fig
2011-6-14
x = 14464000000000000; % An initial value
x = min(x,32768) % Limit the value to 32768
I am not clear on what you mean by, "the shortest integer," but this will work with arrays too.
x = [200 50 0 7e20 2e14 44 10e10] % Initial values.
x = min(x,32768) % Limit the value to 32768
类别
在 帮助中心 和 File Exchange 中查找有关 Sparse Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!