MATLAB REAL-TIME WORKSHOP 7 - TARGET LANGUAGE COMPILER Manuel d'utilisateur Page 205

  • Télécharger
  • Ajouter à mon manuel
  • Imprimer
  • Page
    / 408
  • Table des matières
  • MARQUE LIVRES
  • Noté. / 5. Basé sur avis des utilisateurs
Vue de la page 204
Working with Java Arrays
5-35
for m = 1:4
for n = 1:5
dblArray(m,n) = java.lang.Double((m*10) + n);
end
end
dblArray
dblArray =
java.lang.Double[][]:
[11] [12] [13] [14] [15]
[21] [22] [23] [24] [25]
[31] [32] [33] [34] [35]
[41] [42] [43] [44] [45]
Another Way to Create a Java Array
You can also create an array of Java objects using syntax that is more typical
to MATLAB. For example, the following syntax creates a 4-by-5 MATLAB
array of type double and assigns zero to each element of the array.
matlabArray(4,5) = 0;
You use similar syntax to create a Java array in MATLAB, except that you
must specify the Java class name. The value being assigned,
0 in this example,
is stored in the final element of the array, javaArray
(4,5). All other elements
of the array receive the empty matrix.
javaArray(4,5) = java.lang.Double(0)
javaArray =
java.lang.Double[][]:
[] [] [] [] []
[] [] [] [] []
[] [] [] [] []
[] [] [] [] [0]
Note You cannot change the dimensions of an existing Java array as you can
with a MATLAB array. The same restriction exists when working with Java
arrays in the Java language. See the example below.
Vue de la page 204
1 2 ... 200 201 202 203 204 205 206 207 208 209 210 ... 407 408

Commentaires sur ces manuels

Pas de commentaire