You can move data from a C MEX file into anmxArray
using the C Matrix API. The functions you use depend on the type of data in your application. Use themxSetDoubles
andmxGetDoubles
functions for data of typedouble
. For numeric data other thandouble
, use the one of the typed data access functions. For nonnumeric data, see the examples for themxCreateString
function.
The following examples use a variabledata
to represent data from a computational routine. Each example creates anmxArray
using themxCreateNumericMatrix
function, fills it withdata
, and returns it as the output argumentplhs[0]
.
如果你有复杂的数据类型或不是double
, then use theTyped Data Access in C MEX Filesfunctions. The typed data access functions are part of the interleaved complex C Matrix API; use themex
-R2018a
option to build the MEX functions.
ThearrayFillGetPr.c
example uses themxGetDoubles
function to copy the values fromdata
toplhs[0]
.
ThearrayFillSetPr.c
example uses themxSetDoubles
function to pointplhs[0]
todata
. ThearrayFillSetPrComplex.c
example uses themxSetComplexDoubles
function to point to complexdata
.
The examplearrayFillSetData.c
shows how to fill anmxArray
for numeric types other thandouble
.
mxGetDoubles
|mxSetDoubles
|mxCreateString
|mxSetComplexDoubles