Put the MATLAB® interface file on the MATLAB path using the addpath
function.
The C++ shared library file and its dependencies, if any, must be on your system path or run-time search path (rpath). For more information, see Set Run-Time Library Path for C++ Interface.
To call a function in a C++ library, use the MATLAB
clib
package. MATLAB automatically loads the library when you type:
memberName = "fully-qualified-class-member";
clib.memberName
After MATLAB loads the library, you can use tab completion to view the members of the
clib
package.
For example, to call function funcname
in library
libname
, type the following statement. funcname
defines the input arguments arg1, arg2, ...
and the output argument
retVal
.
retVal = clib.libname.funcname(arg1, arg2, ...)