MATLAB BUILDER JA 2 Podręcznik Użytkownika Strona 62

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 292
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 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
Przeglądanie stron 61
1 2 ... 57 58 59 60 61 62 63 64 65 66 67 ... 291 292

Komentarze do niniejszej Instrukcji

Brak uwag