Documentation

This is machine translation

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

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

Access Data

Read or write data to array

Use these functions to get information about a MATLAB® array, such as dimension and size, and to retrieve data elements based on type. Use these functions to write data to mxArray variables.

C Functions

mxGetNumberOfDimensionsNumber of dimensions in array
mxGetElementSizeNumber of bytes required to store each data element
mxGetDimensionsPointer to dimensions array
mxSetDimensionsModify number of dimensions and size of each dimension
mxGetNumberOfElementsNumber of elements in array
mxCalcSingleSubscriptOffset from first element to desired element
mxGetMNumber of rows in array
mxSetMSet number of rows in array
mxGetNNumber of columns in array
mxSetNSet number of columns in array
mxGetScalarReal component of first data element in array
mxGetPrReal data elements in array of type DOUBLE
mxSetPrSet new real data elements in array of type DOUBLE
mxGetPiImaginary data elements in array of type DOUBLE
mxSetPiSet new imaginary data elements in array of type DOUBLE
mxGetDataPointer to real numeric data elements in array
mxSetDataSet pointer to real numeric data elements in array
mxGetImagDataPointer to imaginary data elements in array
mxSetImagDataSet pointer to imaginary data elements in array
mxGetCharsPointer to character array data
mxGetLogicalsPointer to logical array data
mxGetClassIDClass of array
mxGetClassNameClass of array as string
mxSetClassNameStructure array to MATLAB object array
mxGetPropertyValue of public property of MATLAB object
mxSetPropertySet value of public property of MATLAB object
mxGetFieldPointer to field value from structure array, given index and field name
mxSetFieldSet field value in structure array, given index and field name
mxGetNumberOfFieldsNumber of fields in structure array
mxGetFieldNameByNumberPointer to field name from structure array, given field number
mxGetFieldNumberField number from structure array, given field name
mxGetFieldByNumberPointer to field value from structure array, given index and field number
mxSetFieldByNumberSet field value in structure array, given index and field number
mxAddFieldAdd field to structure array
mxRemoveFieldRemove field from structure array
mxGetCellPointer to element in cell array
mxSetCellSet contents of cell array
mxGetNzmaxNumber of elements in IR, PR, and PI arrays
mxSetNzmaxSet storage space for nonzero elements
mxGetIrSparse matrix IR array
mxSetIrIR array of sparse array
mxGetJcSparse matrix JC array
mxSetJcJC array of sparse array

Topics

Handle Complex Data

MATLAB separates complex data into real and imaginary parts.

Handle Sparse Arrays

The MATLAB API provides a set of functions that allow you to create and manipulate sparse arrays from within your MEX files.

Manipulate Multidimensional Numerical Arrays

You can manipulate multidimensional numerical arrays by using mxGetData and mxGetImagData.

Was this topic helpful?