MATLAB REAL-TIME WORKSHOP 7 - TARGET LANGUAGE COMPILER Instrukcja Użytkownika Strona 214

  • Pobierz
  • Dodaj do moich podręczników
  • Drukuj
  • Strona
    / 408
  • Spis treści
  • BOOKMARKI
  • Oceniono. / 5. Na podstawie oceny klientów
Przeglądanie stron 213
5 Calling Java from MATLAB
5-44
% Concatenate the two along the second dimension.
d3 = cat(2,d1,d2)
d3 =
java.lang.Double[][]:
[2] [4] [6] [ 8] [10]
[3] [5] [7] [ 9] [11]
[4] [6] [8] [10] [12]
Creating a New Array Reference
Because Java arrays in MATLAB are references, assigning an array variable to
another variable results in a second reference to the array.
Consider the following example where two separate array variables reference
a common array. The original array,
origArray, is created and initialized. The
statement
newArrayRef = origArray creates a copy of this array variable.
Changes made to the array referred to by
newArrayRef also show up in the
original array.
origArray = javaArray('java.lang.Double', 3, 4);
for m = 1:3
for n = 1:4
origArray(m,n) = java.lang.Double((m * 10) + n);
end
end
origArray
origArray =
java.lang.Double[][]:
[11] [12] [13] [14]
[21] [22] [23] [24]
[31] [32] [33] [34]
% ----- Make a copy of the array reference -----
newArrayRef = origArray;
newArrayRef(3,:) = java.lang.Double(0);
origArray
origArray =
Przeglądanie stron 213
1 2 ... 209 210 211 212 213 214 215 216 217 218 219 ... 407 408

Komentarze do niniejszej Instrukcji

Brak uwag