Main Content

mxSetPi (C)

(Not recommended) Set imaginary data elements in mxDOUBLE_CLASS array

mxSetPi is not available in the interleaved complex API. Use mxSetComplexDoubles instead. For more information, see Compatibility Considerations.

C Syntax

#include "matrix.h"
void mxSetPi(mxArray *pm, double *pi);


Use mxSetPi to set the imaginary data of the specified mxArray.

Most mxCreate* functions optionally allocate heap space to hold imaginary data. If you allocate heap space when calling an mxCreate* function, then do not use mxSetPi to initialize the imaginary elements of the array. Instead, call this function to replace existing values with new values. Examples of allocating heap space include setting the ComplexFlag to mxCOMPLEX or setting pi to a non-NULL value.

The mxSetPi function does not free any memory allocated for existing data that it displaces. To free existing memory, call mxFree on the pointer returned by mxGetPi.

Input Arguments

expand all

Pointer to a MATLAB array of type mxDOUBLE_CLASS, specified as mxArray *.

Pointer to the first mxDouble element of the imaginary part of the data array within an mxArray, specified as double *. Each element in the array contains the imaginary 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 pi points to static memory, then memory leaks and other memory errors can result.

Version History

Introduced before R2006a

expand all