User`s guide

Passing Arguments to and from Java
varargout{i} = rand(1, i);
end
This function returns a list of random double vectors such that the length
of the
ith vector is equal to i. The MATLAB C ompiler generates a Java
interface to this function as follows:
/* mlx interface - List version */
public void randvectors(List lhs, List rhs) throws MWException
{
(implementation omitted)
}
/* mlx interface Array version */
public void randvectors(Object[] lhs, Object[] rhs) throws MWException
{
(implementation omitted)
}
/* Standard interface no inputs*/
public Object[] randvectors(int nargout) throws MWException
{
(implementation omitted)
}
Code Fragment: Passing Optional Arguments with th e Standard
Inter face. Here is one way to use the
randvectors method in a Java
program:
public double[][] getrandvectors(int n) throws MWException
{
myclass cls = null;
Object[] y = null;
try
{
cls = new myclass();
y = cls.randvectors(n);
double[][] ret = new double[y.length][];
for (int i = 0; i < y.length; i++)
ret[i] = (double[])((MWArray)y[i]).getData();
3-13