Documentation

This is machine translation

Translated by Microsoft
Mouse over text to see original. Click the button below to return to the English verison of the 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

mxGetNumberOfDimensions Number of dimensions in array
mxGetElementSize Number of bytes required to store each data element
mxGetDimensions Pointer to dimensions array
mxSetDimensions Modify number of dimensions and size of each dimension
mxGetNumberOfElements Number of elements in array
mxCalcSingleSubscript Offset from first element to desired element
mxGetM Number of rows in array
mxSetM Set number of rows in array
mxGetN Number of columns in array
mxSetN Set number of columns in array
mxGetScalar Real component of first data element in array
mxGetPr Real data elements in array of type DOUBLE
mxSetPr Set new real data elements in array of type DOUBLE
mxGetPi Imaginary data elements in array of type DOUBLE
mxSetPi Set new imaginary data elements in array of type DOUBLE
mxGetData Pointer to real numeric data elements in array
mxSetData Set pointer to real numeric data elements in array
mxGetImagData Pointer to imaginary data elements in array
mxSetImagData Set pointer to imaginary data elements in array
mxGetChars Pointer to character array data
mxGetLogicals Pointer to logical array data
mxGetClassID Class of array
mxGetClassName Class of array as string
mxSetClassName Structure array to MATLAB object array
mxGetProperty Value of public property of MATLAB object
mxSetProperty Set value of public property of MATLAB object
mxGetField Pointer to field value from structure array, given index and field name
mxSetField Set field value in structure array, given index and field name
mxGetNumberOfFields Number of fields in structure array
mxGetFieldNameByNumber Pointer to field name from structure array, given field number
mxGetFieldNumber Field number from structure array, given field name
mxGetFieldByNumber Pointer to field value from structure array, given index and field number
mxSetFieldByNumber Set field value in structure array, given index and field number
mxAddField Add field to structure array
mxRemoveField Remove field from structure array
mxGetCell Pointer to element in cell array
mxSetCell Set contents of cell array
mxGetNzmax Number of elements in IR, PR, and PI arrays
mxSetNzmax Set storage space for nonzero elements
mxGetIr Sparse matrix IR array
mxSetIr IR array of sparse array
mxGetJc Sparse matrix JC array
mxSetJc JC 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?