MATLAB BUILDER JA 2 Guía de usuario Pagina 203

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 292
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 202
Using Class Methods
Structure data S(1,1).f2 is 555
getData. This method returns a one-dimensional array containing a copy
of the data in the underlying MATLAB array. The
getData method of
MWStructArray ov erride s the getData method of class MWArray.
The prototype for the
getData method is
public Object getData()
getData
returns a one-dimensional array of e lements stored in column-wise
order. Before converting, a new array is derived by transforming the struct
array into a cell array such that an N-by-M-by-... struct array with P fields
is transformed into a P-by-N-by-M-by-... cell array. Each element in the
returned array is converted to a Java a rray when you call
MWArray.toArray()
on the corresponding cell.
Input Parameters
None
Example Getting Structure Array Data with getData
Get the data stored in all field s an d in dices of MWStructArray object S:
int[] sdims = {1, 2};
String[] sfields = {"f1", "f2", "f3"};
MWStructArray S = new MWStructArray(sdims, sfields);
int count = S.numberOfElements() * S.numberOfFields();
// Initialize the structure.
Integer[] val = new Integer[6];
for (int i = 0; i < count; i++)
val[i] = new Integer((i+1) * 15);
// Use getData to get data from the structure.
System.out.println("Data read from structure array S: \n");
4-127
Vista de pagina 202
1 2 ... 198 199 200 201 202 203 204 205 206 207 208 ... 291 292

Comentarios a estos manuales

Sin comentarios