MATLAB BUILDER JA 2 User's Guide Page 50

  • Download
  • Add to my manuals
  • Print
  • Page
    / 292
  • Table of contents
  • BOOKMARKS
  • Rated. / 5. Based on customer reviews
Page view 49
3 Programming
Object[] y = null;
try
{
cls = new myclass();
y = cls.myprimes(1, new Double((double)n));
return (double[])((MWArray)y[0]).getData();
}
finally
{
MWArray.disposeArray(y);
if (cls != null)
cls.dispose();
}
}
}
The import statements at the beginning of the program import packages that
define all the classes that the program requires. These classes are defined in
javabuilder.* and mycomponent.*; the latter defines the class myclass.
The following statement instantiates the class
myclass:
cls = new myclass();
The following statement calls the class method myprimes:
y = cls.myprimes(1, new Double((double)n));
Thesamplecodepassesajava.lang.Double to the myprimes method. The
java.lang.Double is automatically converted to the double data type
required by the encapsu la ted MATLAB
myprimes function.
When
myprimes executes, it finds all prime numbers between 0 and the input
value and returns this in a MATLAB
double array. This array is returned
to the Jav a program as an
MWNumericArray with its MWClassID property set
to
MWClassID.DOUBLE.
The
myprimes method encapsulates the myprimes function.
3-4
Page view 49
1 2 ... 45 46 47 48 49 50 51 52 53 54 55 ... 291 292

Comments to this Manuals

No comments