MATLAB: Given a positive number , how to determine its surrounding integers

for loopif statement

Can someone please explain how to get the surrounding integers for a given positive number ( for ex. if number is 1.23 then it should return 1 and 2 )
I actually need this to determine that the given number is between 0-1 or 2-3 or 4-5 and so on….

Best Answer

What would
ceil(x)
and
floor(x)
tell you? Or for that matter, what would floor(x)+1 be?
You need to decide if x is already an integer, what you want to see however.