User`s guide
mbint
7-11
7mbint
Purpose Assert variable is integer
Syntax mbint(n)
Description The statement
mbint(x)
causes the MATLAB Compiler to impute that x is an integer. At run-time, if
mbint determines that x holds a noninteger value, the generated code issues an
error message and halts execution of the MEX-file.
mbint tells the MATLAB interpreter to check whether x holds an integer value.
If
x does not, mbint issues an error message and halts execution of the M-file.
The MATLAB interpreter does not use
mbint to impute a data type to x.
Note that
mbint only tests x at the point in an M-file or MEX-file where an
mbint call appears. In other words, an mbint call tests the value of x only once.
If
x becomes a noninteger after the mbint test, mbint cannot issue an error
message.
mbint defines an integer as any scalar, vector, or matrix that contains only
integer or string values. For example,
mbint considers n to be an integer
because all elements in
n are integers.
n = [5 7 9];
If even one element of n contains a fractional component, for example,
n = [5 7 9.2];
then mbint assumes that n is not an integer.
mbint considers all strings to be integers.
If
n is a complex number, then mbint considers n to be an integer if both its real
and imaginary parts are integers. For example,
mbint considers the value of n
an integer.
n = 4 + 7i
mbint
does not consider the value of x an integer because one of the parts (the
imaginary) has a fractional component: