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.

mxSetData (C and Fortran)

Set pointer to real numeric data elements in array

C Syntax

#include "matrix.h"
void mxSetData(mxArray *pm, void *pr);

Fortran Syntax

#include "fintrf.h"
subroutine mxSetData(pm, pr)
mwPointer pm, pr



Pointer to an mxArray


Pointer to an array. Each element in the array contains the real component of a value. The array must be in dynamic memory; call mxCalloc to allocate this memory. Do not use the ANSI® C calloc function, which can cause memory alignment issues leading to program termination.


mxSetData is like mxSetPr, except that in C, its second argument is a void *. Use this function on numeric arrays with contents other than double.

This function does not free any memory allocated for existing data that it displaces. To free existing memory, call mxFree on the pointer returned by mxGetData before you call mxSetData.


See the following examples in matlabroot/extern/examples/refbook.

Introduced before R2006a

Was this topic helpful?