MATLAB BUILDER JA 2 Guía de usuario Pagina 146

  • Descarga
  • Añadir a mis manuales
  • Imprimir
  • Pagina
    / 292
  • Tabla de contenidos
  • MARCADORES
  • Valorado. / 5. Basado en revisión del cliente
Vista de pagina 145
4 Using MWArra y Classes
(1,4) 16.0000 +41.0000i
(2,5) 0 + 2.0000i
Example Using newSparse with Row and Column Indices
Construct a sparse MWNumericArray from vector Adata:
double[] Adata = { 0, 10, 0, 0, 40, 50, 60, 0, 0, 90};
int[] ri = {1, 1, 1, 1, 1, 2, 2, 2, 2, 2};
int[] ci = {1, 2, 3, 4, 5, 1, 2, 3, 4, 5};
MWNumericArray A = MWNumericArray.newSparse(ri, ci,
Adata, MWClassID.DOUBLE);
System.out.println("A = " + A.toString());
When run, the example displays this output:
(2,1) 50
(1,2) 10
(2,2) 60
(1,5) 40
(2,5) 90
Example Assigning Multiple Values to a Single Array Element
Create a sparse MWNumericArray using the rowindex and colindex
arguments, specifying multiple values for the array element at index (2, 5).
The result is that this element stores the sum of the values from
Adata(1),
Adata(7), Adata(8),andAdata(9), which is equal to 250.
double[] Adata = { 0, 10, 0, 0, 40, 50, 60, 70, 80, 90};
int[] ri = {1, 2, 1, 1, 1, 2, 2, 2, 2, 2};
int[] ci = {1, 5, 2, 3, 5, 1, 2, 5, 5, 5};
MWNumericArray A =
MWNumericArray.newSparse(ri, ci, Adata, 4, 5,
MWClassID.DOUBLE);
4-70
Vista de pagina 145
1 2 ... 141 142 143 144 145 146 147 148 149 150 151 ... 291 292

Comentarios a estos manuales

Sin comentarios