MATLAB Application Program Interface
  Go to function:
    Search    Help Desk 
mxGetName    Examples   See Also

Get the name of the specified mxArray

C Syntax

Arguments

array_ptr
  Pointer to an mxArray.

Returns

A pointer to the start of the name field. If the mxArray has no name, the first element in the name field is \0.

Description

Use mxGetName to determine the name of the mxArray that array_ptr points to.

The returned name is a NULL-terminated character string. MATLAB variable names are stored in fixed-length character arrays of length mxMAXNAM+1, where mxMAXNAM is defined in the file mxArray.h. Thus variable names can by any length up to mxMAXNAM. The actual length is determined by the NULL terminator.

mxGetName passes back a pointer to an existing section of memory; therefore, your application should not allocate space to hold the returned name string. Do not attempt to deallocate or free the returned string.

Examples

Consider a MEX-file named ret_name that returns the name of the first input mxArray

If you pass a named mxArray to ret_name, then ret_name prints the mxArray's name; for example:

However, passing an unnamed mxArray

For an additional example, see mxgetname.c in the mx subdirectory of the examples directory.

See Also

mxSetName



[ Previous | Help Desk | Next ]