Round up to the next integer
ceil function in MATLAB®, see
MuPAD® notebooks are not recommended. Use MATLAB® live scripts instead.
MATLAB live scripts support most MuPAD functionality, though there are some differences. For more information, see Convert MuPAD Notebooks to MATLAB Live Scripts.
ceil rounds a number to the next larger integer.
For complex arguments,
ceil rounds the real
and the imaginary parts separately.
For real numbers and exact expressions representing real numbers,
For arguments that contain symbolic identifiers,
unevaluated function calls.
For floating-point intervals,
floating-point intervals containing all the results of applying
the real or complex numbers inside the interval.
Note: If the argument is a floating-point number of absolute value larger than 10DIGITS, the resulting integer is affected by internal non-significant digits. See Example 2.
Internally, exact numerical expressions that are neither integers
nor rational numbers are approximated by floating-point numbers before
rounding. Thus, the resulting integer depends on the current
The functions are sensitive to the environment variable
determines the numerical working precision.
Round the following real and complex numbers:
ceil(3.5), ceil(-7/2), ceil(3 + 5/2*I)
Round the following symbolic expression representing a number:
ceil(PI*I + 7*sin(exp(2)))
Rounding of expressions with symbolic identifiers produces unevaluated function calls:
Rounding floating-point numbers of large absolute value is affected by internal non-significant digits:
x := 10^30/3.0
Note that only the first 10 decimal digits are "significant". Further digits are subject to round-off effects caused by the internal binary representation. These "insignificant" digits are part of the integer produced by rounding:
Exact numerical expressions are internally converted to floating-point
numbers before rounding. Consequently, the current setting of
affect the result:
x := 10^30 - exp(30)^ln(10)
Note that the exact value of this number is 0. Floating-point evaluation is subject to severe cancellations:
DIGITS := 10: float(x), ceil(x)
The floating-point result is more accurate when calculated with a higher precision. The rounded values change accordingly:
DIGITS := 20: float(x), ceil(x)
DIGITS := 30: float(x), ceil(x)
delete x, DIGITS:
On floating-point intervals,
This interval containa the results of
Because there are finite numbers represented as
ceil returns very small or large
representable numbers in certain cases: