This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English version of the page.

Note: This page has been translated by MathWorks. Click here to see
To view all translated materials including this page, select Country from the country navigator on the bottom of this page.

Fill mxArray


You can move data from a C MEX file into an mxArray using the C Matrix API. The functions you use depend on the type of data in your application. Use the mxSetDoubles and mxGetDoubles functions for data of type double. For numeric data other than double, use the one of the typed data access functions. For nonnumeric data, see the examples for the mxCreateString function.

The following examples use a variable data to represent data from a computational routine. Each example creates an mxArray using the mxCreateNumericMatrix function, fills it with data, and returns it as the output argument plhs[0].

If you have complex data or the type is not double, then use the Typed Data Access functions. The typed data access functions are part of the interleaved complex C Matrix API; use the mex -R2018a option to build the MEX functions.

Copying Data Directly into an mxArray

The arrayFillGetPr.c example uses the mxGetDoubles function to copy the values from data to plhs[0].

Pointing to Data

The arrayFillSetPr.c example uses the mxSetDoubles function to point plhs[0] to data. The arrayFillSetPrComplex.c example uses the mxSetComplexDoubles function to point to complex data.

The example arrayFillSetData.c shows how to fill an mxArray for numeric types other than double.

See Also

| | |

Related Topics