MATLAB BUILDER JA 2 Guide de l'utilisateur Page 62

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 292
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 61
3 Programming
}
else if (a instanceof byte[][])
{
byte[][] x = (byte[][])a;
/* (do something with x...) */
}
else
{
throw new MWException(
"Bad type returned from myprimes");
}
}
This example uses the toArray method (see “Methods to Copy, Convert,
and Compare MWArrays” on p age 4-49) to return a Java primitive array
representing the underlying MATLAB array. The
toArray method works just
like
getData in the previous examples, except that the returned array has the
same dimensionality as the underlying MATLAB array.
Code Fragment: Using MWArray Query
The next example uses the MWArray classID method (see “Methods to
Return Information About an MWArray” on page 4-40) to determine the
type of the underlying MATLAB array. It also checks the dimensionality by
calling
numberOfDimensions. If any unexpected information is returned, an
exception is thrown. It then checks the
MWClassID and processes the array
accordingly.
public void getprimes(int n) throws MWException
{
myclass cls = null;
Object[] y = null;
try
{
cls = new myclass();
y = cls.myprimes(1, new Double((double)n));
3-16
Vue de la page 61
1 2 ... 57 58 59 60 61 62 63 64 65 66 67 ... 291 292

Commentaires sur ces manuels

Pas de commentaire