Main Content

Limitations Using Structures

MATLABReturns Pointers to Structures

MATLAB®returns pointers to structures. Return by value is not supported.

Structure Cannot Contain Pointers to Other Structures

Nested structures or structures containing a pointer to a structure are not supported. However, MATLAB can access an array of structures created in an external library.

Requirements forMATLABStructure Arguments

When you pass a MATLAB structure to an external library function, the field names must meet the following requirements.

  • Every MATLAB field name must match a field name in the library structure definition.

  • MATLAB structures cannot contain fields that are not in the library structure definition.

  • If a MATLAB structure contains fewer fields than defined in the library structure, MATLAB sets undefined fields to zero.

  • Field names are case-sensitive. For example, suppose that librarymylibcontains functionmyfuncwith the following structure definition.

    结构体S { double len; };

    The field name islen. If you pass a structure tomyfuncwith the field nameLen, MATLAB displays an error.

    S.Len = 100; calllib('mylib','myfunc',S)

Requirements for C结构体Field Names

When MATLAB loads a C结构体definition, the field names in MATLAB are not case-sensitive. For example, when you load a library containing the following definition, MATLAB does not create two fields.

结构体S { double Num; double num; };

Related Topics