MATLAB Compiler    
mbint

Assert variable is integer

Syntax

Description

The statement

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.

If even one element of n contains a fractional component, for example,

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.

mbint does not consider the value of x an integer because one of the parts (the imaginary) has a fractional component:

Example

This code in MATLAB causes mbint to generate an error message because n does not hold an integer value:

See Also

mbintscalar, mbintvector, mcc


  mbcharvector mbintscalar