Documentation

This is machine translation

Translated by Microsoft
Mouseover text to see original. Click the button below to return to the English verison of the page.

Note: This page has been translated by MathWorks. Please click here
To view all translated materals including this page, select Japan from the country navigator on the bottom of this page.

com.mathworks.matlab.types.HandleObject class

Package: com.mathworks.matlab.types

Java class to represent MATLAB handle objects

Description

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

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

Examples

expand all

This example starts a shared MATLAB session and creates a containers.Map object in the MATLAB workspace. The statement evaluated in the MATLAB workspace returns a handle variable that refers to the Map object.

The engine getVariable function returns the MATLAB handle variable as a HandleObject instance. This instance is used to call the MATLAB containers.Map.keys function to obtain the Map keys.

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

Was this topic helpful?