Tag Archives: round

The usage of several integer functions in MATLAB (fix, floor, ceil, round)

There are the following integer functions in Matlab: fix, floor, ceil, round, and their differences are as follows


Fix: round in the direction of 0

>>fix(2.8) = 2
>>fix(-2.8) = -2

Floor: round in the direction of negative infinity

>>floor(2.8) = 2
>>floor(-2.8) = -3

Ceil: round in the direction of positive infinity

>>ceil(2.8) = 3
>>ceil(-2.8) = -2

Round: round to the nearest integer

>>round(2.8) = 3
>>round(-2.8) = -3