External Interfaces Reference Previous page   Next Page
libstruct

Construct structure as defined in external library

Syntax

Description

s = libstruct('type') returns a libstruct object s that is a MATLAB object designed to resemble a C structure of type structtype. The structure type, structtype, is defined in an external library that must be loaded into MATLAB using the loadlibrary function. All fields of s are set to zero.

s = libstruct('structtype', mlstruct) returns a libstruct object s with its fields initialized from MATLAB structure, mlstruct.

The libstruct function essentially creates a C-like structure that you can pass to functions in an external library. You can handle this structure in MATLAB as you would a true MATLAB structure.

Examples

This example performs a simple addition of the fields of a structure. The function addStructFields is defined in the MATLAB sample shared library, shrlibsample.

Here is the C function:

Start by loading the shrlibsample library and creating MATLAB structure, sm:

Construct a libstruct object sc that uses the c_struct template:

Now call the function, passing the libstruct object, sc:

See Also

loadlibrary, libfunctions, libfunctionsview, libpointer, calllib, libisloaded, unloadlibrary


Previous page  libpointer loadlibrary Next page

© 1994-2005 The MathWorks, Inc.