Documentation Center

  • Trial Software
  • Product Updates

mxCreateDoubleScalar (C and Fortran)

Scalar, double-precision array initialized to specified value

C Syntax

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

Fortran Syntax

mwPointer mxCreateDoubleScalar(value)
real*8 value

Arguments

value

Value to which you want to initialize the array

Returns

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.

Description

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

Alternatives

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)
Was this topic helpful?