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.

mxCreateDoubleScalar (C and Fortran)

Scalar, double-precision array initialized to specified value

C Syntax

#include "matrix.h"
mxArray *mxCreateDoubleScalar(double value);

Fortran Syntax

#include "fintrf.h"
mwPointer mxCreateDoubleScalar(value)
real*8 value



Value to which you want to initialize the array


Pointer to the created mxArray, if successful. If unsuccessful in a standalone (non-MEX file) application, returns NULL in C (0 in Fortran). If unsuccessful in a MEX file, the MEX file terminates and returns control to the MATLAB® prompt. The function is unsuccessful when there is not enough free heap space to create the mxArray.


Call mxCreateDoubleScalar to create a scalar double mxArray. When you finish using the mxArray, call mxDestroyArray to destroy it.


C Language

In C, you can replace the statements:

pa = mxCreateDoubleMatrix(1, 1, mxREAL);
*mxGetPr(pa) = value;

with a call to mxCreateDoubleScalar:

pa = mxCreateDoubleScalar(value);

Fortran Language

In Fortran, you can replace the statements:

pm = mxCreateDoubleMatrix(1, 1, 0)
mxCopyReal8ToPtr(value, mxGetPr(pm), 1)

with a call to mxCreateDoubleScalar:

pm = mxCreateDoubleScalar(value)

Introduced before R2006a

Was this topic helpful?