Round to shortest integer
Show older comments
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.
Answers (1)
Matt Fig
on 14 Jun 2011
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
Categories
Find more on Sparse Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!