User`s manual
Passing Data to a Java Method
5-49
[poly.xpoints poly.ypoints] % Verify the coordinates
ans =
14 55
42 12
98 -2
124 62
MATLAB Arrays Are Passed by Value
Since MATLAB arrays are passed by value, any changes that a Java method
makes to them will not be visible to your MATLAB code. If you need to access
changes that a Java method makes to an array, then, rather than passing a
MATLAB array, you should create and pass a Java array, which is a reference.
For a description of using Java arrays in MATLAB, see “Working with Java
Arrays” on page 5-29.
Note Generally, it is preferable to have methods return data that has been
modified using the return argument mechanism as opposed to passing a
reference to that data in an argument list.
Passing String Arguments
To call a Java method that has an argument defined as an object of class
java.lang.String, you can pass either a String object that was returned from
an earlier Java call or a MATLAB 1-by-n character array. If you pass the
character array, MATLAB converts the array to a Java object of
java.lang.String for you.
For a programming example, see “Example – Reading a URL” on page 5-63.
This shows a MATLAB character array that holds a URL being passed to the
Java
URL class constructor. The constructor, shown below, expects a Java
String argument.
public URL(String spec) throws MalformedURLException