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.

mxSetPr (C)

Set real data elements in mxDOUBLE_CLASS array

mxSetPr is not recommended for C applications. Use mxSetDoubles instead. For more information, see Typed Data Access.

C Syntax

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

Description

mxSetPr sets the real data of a real mxDOUBLE_CLASS array pm. If you build with the interleaved complex API (mex -R2018a option) and pm is complex, then the function terminates the MEX file and returns control to the MATLAB® prompt. In a non-MEX file application, the function returns NULL.

Call mxIsDouble to validate the mxArray type. Call mxIsComplex to determine that the data is real.

All mxCreate* functions allocate heap space to hold data. Therefore, you do not ordinarily use this function to initialize the real elements of an array. Rather, call this function to replace the existing values with new values.

This function does not free memory allocated for existing data. To free existing memory, call mxFree on the pointer returned by mxGetPr.

Input Arguments

expand all

Pointer to an mxDOUBLE_CLASS array.

Pointer to the first element of 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. If pr points to static memory, then memory leaks and other memory errors can result.

API Version

This function is in the separate complex API. To build myMexFile.c using this function, type:

mex -R2017b myMexFile.c

This function is also in the interleaved complex API. However, the function errors for complex input argument pm. MathWorks recommends that you upgrade your MEX file to use the Typed Data Access functions instead.

To build myMexFile.c using the interleaved complex API, type:

mex -R2018a myMexFile.c

Introduced before R2006a