How to determine whether input is integer

The easiest and fastest way to check if a variable is an integer independently of its format is to compare the input with its rounded version, for example:

x==floor(x)

If we are just interested in knowing if the input is an integer matlab variable (sint or uint) we can use isainteger Matlab function.


La forma más fácil y rápida para comprobar si una variable es un número entero independientemente de su formato es comparar la entrada con su versión redondeada, por ejemplo:

x==floor(x)

Si solo estamos interesados en saber si la entrada es una variable en formato entero de matlab (sint o uint) podemos utilizar la función isainteger de Matlab.

Advertisements
This entry was posted in Sin categoría and tagged , , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s