Main Content

com.mathworks.matlab.types.ValueObject

Abstract Java class to represent MATLAB value objects

Description

Java® represents value objects that are passed from MATLAB® as instances of the ValueObject class.

Creation

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

Examples

expand all

Create a polygon and call the numsides method.

import com.mathworks.engine.*;
import com.mathworks.matlab.types.*;

public class PassValueObject {
    public static void main(String[] args) throws Exception {
        MatlabEngine eng = MatlabEngine.startMatlab();

        // CREATE VALUE OBJECT pgon = polyshape([0 0 1 3], [0 3 3 0]);        
        ValueObject pgon = eng.feval("polyshape", new int[]{0,0,1,3}, new int[]{0,3,3,0});

        // CALL METHOD res = numsides(pgon)
        ns = eng.feval("numsides", pgon);
        System.out.println("Number of sides: " + ns);
        eng.close();
    }
}
Introduced in R2021a