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.

Respuestas (1)

Matt Fig
Matt Fig el 14 de Jun. de 2011

0 votos

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

Categorías

Más información sobre Sparse Matrices en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 14 de Jun. de 2011

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by