External Interfaces Reference Previous page   Next Page
libpointer

Create pointer object for use with external libraries

Syntax

Description

p = libpointer returns an empty (void) pointer.

p = libpointer('type') returns an empty pointer that contains a reference to the specified data type. This type can be any MATLAB numeric type, or a structure or enumerated type defined in an external library that has been loaded into MATLAB with the loadlibrary function. For valid types, see the table under Primitive Types in the MATLAB documentation.

p = libpointer('type', value) returns a pointer to the specified data type and initialized to the value supplied.

Examples

This example passes an int16 pointer to a function that multiplies each value in a matrix by its index. The function multiplyShort is defined in the MATLAB sample shared library, shrlibsample.

Here is the C function:

Load the shrlibsample library. Create the matrix, v, and also a pointer to it, pv:

Now call the C function in the library, passing the pointer to v. If you were to pass a copy of v, the results would be lost once the function terminates. Passing a pointer to v enables you to get back the results:

See Also

loadlibrary, libfunctions, libfunctionsview, libstruct, calllib, libisloaded, unloadlibrary


Previous page  libisloaded libstruct Next page

© 1994-2005 The MathWorks, Inc.