User`s guide
Passing Arguments to and from Java
double Adata = 24;
MWNumericArray A = new MWnumericArray(Adata);
System.out.println("Array A is of type " + A.classID());
Java Builder converts the input argument to an instance of MWNumericArray,
with a
ClassID property of MWClassID.DOUBLE.ThisMWNumericArray object
is the equivalent of a MATLAB 1-by-1
double array.
When you run this example, the results are as follows:
Array A is of type double
Changing the Default by Specifying the Type
When calling an MWArray class method constructor, supply ing a specific data
type causes Java Builder to convert to that type instead of the default.
For example, in the following code fragment, the code specifies that
A should
be constructed as a MATLAB 1-by-1 16-bit integer array:
double Adata = 24;
MWNumericArray A = new MWnumericArray(Adata, MWClassID.INT16);
System.out.println("Array A is of type " + A.classID());
When you run this example, the results are as follows:
Array A is of type int16
Specifying Optional Arguments
So far, the examples have not used M-functions that have varargin or
varargout arguments. Consider the following M-function:
function y = mysum(varargin)
% MYSUM Returns the sum of the inputs.
% Y = MYSUM(VARARGIN) Returns the sum of the inputs.
% This file is used as an example for the MATLAB
% Builder for Java product.
% Copyright 2001-2006 The MathWorks, Inc.
3-9