Main Content

com.mathworks.matlab.types.HandleObject

AbstractJavaclass to representMATLABhandle objects

Description

Java®represents handle objects that are passed from MATLAB®as instances of theHandleObjectclass. When passing a handle object back to MATLAB, Java passes a reference to theHandleObjectinstance. This reference can be either an array or a scalar, depending on the original handle object passed to Java from MATLAB.

Creation

You cannot construct aHandleObjectin Java. You only can pass a handle object to the MATLAB session in which it was originally created.

Examples

expand all

This example starts a shared MATLAB session and creates acontainers.Mapobject in the MATLAB workspace. The statement evaluated in the MATLAB workspace returns a handle variable that refers to theMapobject.

The enginegetVariablefunction returns the MATLAB handle variable as aHandleObjectinstance. This instance is used to call the MATLABkeysfunction to obtain theMapkeys.

import com.mathworks.engine.MatlabEngine; import com.mathworks.matlab.types.*; MatlabEngine engine = MatlabEngine.startMatlab(); engine.eval("cm = containers.Map({'id','name'},{11,'mw'});"); HandleObject handle = engine.getVariable("cm"); String[] cells = engine.feval("keys", handle);
Introduced in R2016b