Convert MATLAB structure to C-style structure for use with shared library
S = libstruct(structtype)
S = libstruct(structtype,mlstruct)
by creating a variable of type
shrlibsample library in the
which contains the
if ~libisloaded('shrlibsample') addpath(fullfile(matlabroot,'extern','examples','shrlib')) loadlibrary('shrlibsample') end
Display function signatures for
search the list for the
The input argument is a pointer to a
Create a MATLAB structure,
sm.p1 = 476; sm.p2 = -299; sm.p3 = 1000;
sc = libstruct('c_struct',sm)
The fields of
sc contain the values of the MATLAB structure,
ans = 1177
To clean up, first clear the
and then unload the library.
clear sc unloadlibrary shrlibsample
Use with libraries that are loaded using the
You can only use the
on scalar structures.
When converting a MATLAB structure to a
the structure must adhere to the requirements listed in Structure Argument Requirements.
If a function in the shared library has a structure
libstruct to create the argument.
libstruct function creates a C-style structure
that you pass to functions in the library. You handle this structure
in MATLAB as you would a true MATLAB structure.