User`s manual
Handling Data Returned from a Java Method
5-59
method of the class to perform the conversion. If you write your own class 
definitions, then you can make use of this feature by writing a 
toChar method 
that performs the conversion according to your own needs.
Note If the class of the specified object is not java.lang.String and it does 
not implement a 
toChar method, then an attempt to convert the object using 
the char function results in an error in MATLAB.
The syntax for the 
char command is as follows, where object is a Java object 
or Java array of objects.
char(object);
Converting to a MATLAB Structure
Java objects are similar to the MATLAB structure in that many of an object’s 
characteristics are accessible via field names defined within the object. You 
may want to convert a Java object into a MATLAB 
structure to facilitate the 
handling of its data in MATLAB. Use the MATLAB 
struct function on the 
object to do this.
The syntax for the 
struct command is as follows, where object is a Java object 
or Java array of objects.
struct(object);
The following example converts a java.awt.Polygon object into a MATLAB 
structure. You can access the fields of the object directly using MATLAB 
structure operations. The last line indexes into the array, pstruct.xpoints, 
to deposit a new value into the third array element.
polygon = java.awt.Polygon([14 42 98 124], [55 12 -2 62], 4);
pstruct = struct(polygon)
pstruct = 
 npoints: 4
 xpoints: [4x1 int32]
 ypoints: [4x1 int32]










