Handle 8-, 16-, 32-, and 64-Bit Data in C MEX File
The C Matrix API provides a set of functions that support signed and unsigned 8-, 16-,
32-, and 64-bit data. For example, the
constructs an unpopulated N-dimensional numeric array with a specified data size. For
more information, see
Once you have created an unpopulated MATLAB® array of a specified data type, you can access the data using the typed
data access functions, like
mxGetComplexInt8s. You can perform arithmetic on data of 8-, 16-, 32-,
or 64-bit precision in MEX files. MATLAB recognizes the correct data class of the result.
doubleelement.c constructs a
2 matrix with unsigned 16-bit integers,
doubles each element, and returns both matrices to MATLAB.
To build this example, at the command prompt type:
mex -R2017b doubleelement.c
Call the example.
ans = 2 6 4 8
The output of this function is a
populated with unsigned 16-bit integers.