MATLAB BUILDER JA 2 Guide de l'utilisateur Page 146

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 292
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 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
Vue de la page 145
1 2 ... 141 142 143 144 145 146 147 148 149 150 151 ... 291 292

Commentaires sur ces manuels

Pas de commentaire