ceil
Rounds toward positive infinity.
Category: Language Fundamentals > Operators and Elementary Operations
Syntax
Y = ceil(X)
Rounds each element of X: toward positive infinity.
Description
ceil returns the smallest integer that is greater than or equal to its argument. Positive values go up and negative values lose their fraction: ceil(-2.5) is -2. Integers, Inf and NaN pass through unchanged.
It is handy to count how many blocks of a given size are needed to cover a length: ceil(n/size).
Input arguments
X- Numeric array. For complex values the real and imaginary parts are processed separately. Integer types are returned unchanged.
Output arguments
Y- Array of the same size and class as
X, holding integer values.
Example
ceil([1.2 -1.2 2 -2.5])
ceil(10/3)
ceil(1.2 + 2.7i)
Output
ans = 1×4
2 -1 2 -2
ans = 4
ans = 2.0000 + 3.0000i