One thing you can do is
abs(b-round(b))<1e-12
or similar, which tests whether b
is within 1e-12
of an integer.
If you want to test many numbers b
, you can have a vector b
, and then
b(abs(b-round(b))<1e-12)
should return the elements of b
that are integers.
There is a Matlab command called isinteger
, DO NOT use it, it is for determining what type of variable something is, you will be using doubles which are a different data type to integers. Just something to be aware of.