If you created the matrixOperations interface in the example Publish Interface to Shared C++ Library on Linux, then you can use it
in this example.
At the operating system prompt, add the path to the C++ shared library file. For more
information, see Set Run-Time Library Path for C++ Interface. Use
rtPath as the output of:
rtPath = fullfile(fullfile(matlabroot,"extern","examples","cpp_interface"),"glnxa64")
C shell command:
setenv LD_LIBRARY_PATH rtPath
Bourne shell command:
LD_LIBRARY_PATH=rtPath:LD_LIBRARY_PATH export LD_LIBRARY_PATH
Start MATLAB®. Add the MATLAB interface file to the MATLAB path.
addpath("~/MATLAB/publisher/matrixexample/matrixlib")At the MATLAB command prompt, display help for the interface. In the example, the
clibgen.generateLibraryDefinition command changed the name of the
interface to matrixOperations to matrixlib. Type this
command to load the package.
doc clib.matrixlib.MatTo display the members of the package, type:
doc clib.matrixlibClasses contained in clib.matrixlib: Mat - clib.matrixlib.Mat Representation of C++ class Mat Functions contained in clib.matrixlib: addMat - clib.matrixlib.addMat Representation of C++ function addMat updateMatByX - clib.matrixlib.updateMatByX Representation of C++ function updateMatByX updateMatBySize - clib.matrixlib.updateMatBySize Representation of C++ function updateMatBySize
To display signatures for the package function, click the links for addMat, updateMatByX, and updateMatBySize.
clib.matrixlib.addMat Representation of C++ function addMat
inputs
mat read-only clib.matrixlib.Mat
outputs
RetVal int32
clib.matrixlib.updateMatByX Representation of C++ function updateMatByX
inputs
mat clib.matrixlib.Mat
X int32
outputs
clib.matrixlib.updateMatBySize Representation of C++ function updateMatBySize
inputs
mat clib.matrixlib.Mat
arr int32
outputs
To display information about class clib.matrixlib.Mat, click the link for
Mat.
clib.matrixlib.Mat Representation of C++ class Mat Method Summary: Mat - clib.matrixlib.Mat Constructor of C++ class Mat Mat - clib.matrixlib.Mat Constructor of C++ class Mat setMat - clib.matrixlib.Mat.setMat Method of C++ class Mat getMat - clib.matrixlib.Mat.getMat Method of C++ class Mat getLength - clib.matrixlib.Mat.getLength Method of C++ class Mat copyMat - clib.matrixlib.Mat.copyMat Method of C++ class Mat
To display constructor and method signatures, use the methods or methodsview functions. For example, type:
methodsview clib.matrixlib.MatTest the functions in the interface. For example, type:
matObj = clib.matrixlib.Mat; % Create a Mat object intArr = [1,2,3,4,5]; matObj.setMat(intArr); % Set the values to intArr retMat = matObj.getMat(5) % Display the values
retMat = 1×5 int32 row vector 1 2 3 4 5