User`s guide

3 Programming
Here is another example:
result = theFourier.plotfft(3, data, new Double(interval));
In this Java statement, the third argument is of type java.lang.Double.
According to conversion rules, the
java.lang.Double automatically converts
to a MATLAB 1-by-1
double array.
Code Fragment: Passing a Java Double Object
The example calls the myprimes method with two arguments. The first
specifies the number of arguments to return. The second is an object of class
java.lang.Double that passes the one data input to myprimes.
cls = new myclass();
y = cls.myprimes(1, new Double((double)n));
This second argument is converted to a MATLAB 1-by-1 double array,
as required by the M-function. This is the default conversion rule for
java.lang.Double.
Code Fragment: Passing an MWArray
This example constructs an MWNumericArray of type MWClassID.DOUBLE.The
call to
myprimes passes the number of outputs, 1,andtheMWNumericArray, x.
x = new MWNumericArray(n, MWClassID.DOUBLE);
cls = new myclass();
y = cls.myprimes(1, x);
Java Builder converts the MWNumericArray object to a MATLAB scalar double
to pass to the M-function.
Code Fragment: Calling MWArray Methods
The conversio n rul es ap pl y no t only when calling your own methods, but
also when calling constructors and factory methods belonging to the
MWArray
classes.
For example, the follow ing code fragment calls the constructor for the
MWNumericArray class with a Java double as the input argument:
3-8