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.Struct class

Package: com.mathworks.matlab.types

Java class to pass MATLAB struct to and from MATLAB

Description

The Struct class provides support for passing data between MATLAB® and Java® as a MATLAB struct. The Struct class implements the java.util.Map interface.

The Struct class is designed as an immutable type. Attempting to change the mappings, keys, or values of the returned Struct causes an UnsupportedOperationException. Calling these methods can cause the exception: put(), putAll(), remove(), entrySet(), keySet(), and values().

For an example, see Using MATLAB Structures in Java.

Constructor Summary

Struct s = new Struct("field1",value1,"field2",value2, ...) creates an instance of Struct with the specified field names and values.

Method Summary

containsKey(Object key)

Returns true if this map contains a mapping for the specified key.

containsValue(Object value)

Returns true if this map maps one or more keys to the specified value.

entrySet()

Returns a Set view of the mappings contained in this map.

equals(Object o)

Compares the specified object with this map for equality.

get(Object key)

Returns the value to which the specified key is mapped, or null if this map contains no mapping for the key.

hashCode()

Returns the hash code value for this map.

isEmpty()

Returns true if this map contains no key-value mappings.

keySet()

Returns a Set view of the keys contained in this map.

size()

Returns the number of key-value mappings in this map.

values()

Returns a Collection view of the values contained in this map.

Examples

expand all

Create a Struct and assign a key and value.

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

class StructProperties {
    public static void main(String[] args) throws Exception {
        MatlabEngine eng = MatlabEngine.startMatlab();
        int[] y = {1,2,3,4,5};
        double[] color = {1.0,0.5,0.7};
        Struct s = new Struct("Color",color,"LineWidth",2);
        eng.feval("plot",y,s);
    }
}

Introduced in R2016b

Was this topic helpful?