MATLAB BUILDER JA 2 Guida Utente Pagina 50

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 292
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 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
Vedere la pagina 49
1 2 ... 45 46 47 48 49 50 51 52 53 54 55 ... 291 292

Commenti su questo manuale

Nessun commento