| Invoking Library Functions After loading a shared library into the MATLAB® workspace, use the calllib function to call functions in the library. Specify the library name, function name, and any arguments that get passed to the function: calllib('libname', 'funcname', arg1, argN) The following example calls functions from the libmx library to test the value stored in y.Toloadthelibrary,type: hfile = [matlabroot '\extern\include\matrix.h']; loadlibrary('libmx', hfile) To create a variable y,type: y = rand(4, 7, 2); To get information about y,type: calllib('libmx', 'mxGetNumberOfElements', y) MATLAB displays: ans = 56 Type: calllib('libmx', 'mxGetClassID', y) MATLAB displays: ans = mxDOUBLE_CLASS For information on how to define the argument types, see "Passing Arguments" on page 2-10. |