MATLAB BUILDER JA 2 Guida Utente Pagina 111

  • Scaricare
  • Aggiungi ai miei manuali
  • Stampa
  • Pagina
    / 292
  • Indice
  • SEGNALIBRI
  • Valutato. / 5. Basato su recensioni clienti
Vedere la pagina 110
Guidelines for Working with MWArray Classes
Method Usage
set(int, Object)
Replaces the element at the one-based index with the
supplied value (inherited from
MWArray).
set(int[],
Object)
Replaces the element at the one-based index array
with the supplied value (inherited from
MWArray).
The set methods replace the cell at the specified i ndex with the supplied
value. ThecellvaluecanbepassedasanysupportedJavatypeorasan
MWArray insta nce. W hen the cell v alue is passed as a Java type, the value is
converted to a MATLAB array using default conversion rules. When the value
is passed as a n
MWArray, the cell is assigned a shared copy of the underlying
MATLAB array.
Using getCell. The
getCell methods return an MWArray in sta n ce of th e
proper subclass type representing a shared copy of the underlying cell. The
array returned by
getCell should be disposed of when it is no longer needed.
This is the m ost efficient way of accessing a cell, because an
MWArray object is
created to encapsulate a shared copy of the underlying array. This process is
significantly more efficient than converting the entire a rray to a Java array
each ti me you access the cell. The ne xt example prints informatio n about a
cell array to standard output:
void printCellInfo(MWCellArray a)
{
if (a == null)
return;
MWArray c = null;
int n = a.numberOfElements();
System.out.println("Number of elements: " + n);
try
{
for (int k = 1; k <= n; k++)
{
c = a.getCell(k);
System.out.println("cell: " + k + " type: " +
a.classID());
c.dispose();
c = null;
4-35
Vedere la pagina 110
1 2 ... 106 107 108 109 110 111 112 113 114 115 116 ... 291 292

Commenti su questo manuale

Nessun commento