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

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 292
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 108
Guidelines for Working with MWArray Classes
Here, each cell is initialized with a Java a rray, and default conversion rules
are used to create the MATLAB array for each cell.
Constructing an MWCellArray Containing Complex Arrays. The next
example creates a helper function that constructs a cell array containing a list
of complex
double arrays. The real and imaginary parts of each cell are passed
in the
re and im arrays, respectively. The new cell array has dimensions
1-by-
N,whereN is the leng th of the inp ut arrays, which must be the same.
MWCellArray createNumericCell(Object[] re, Object[] im)
throws MWException
{
if (re == null || im == null)
throw new MWException("Invalid input");
if (re.length != im.length)
throw new MWException(
"Input arrays must be the same length");
MWCellArray a = null;
MWNumericArray x = null;
try
{
a = new MWCellArray(1, re.length);
for (int k = 1; k <= re.length; k++)
{
x = new MWNumericArray(re[k-1], im[k-1],
MWClassID.DOUBLE);
a.set(k, x);
x.dispose();
x = null;
}
return a;
}
catch (Exception e)
{
if (a != null)
a.dispose();
4-33
Przeglądanie stron 108
1 2 ... 104 105 106 107 108 109 110 111 112 113 114 ... 291 292

Komentarze do niniejszej Instrukcji

Brak uwag