User`s manual
5 Calling Java from MATLAB
5-40
The following example deposits the value 300 in the dblArray element at row 
3, column 2. In Java, this would be 
dblArray[2][1].
dblArray(3,2) = java.lang.Double(300)
dblArray =
java.lang.Double[][]:
 [11] [ 12] [13] [14] [15]
 [21] [ 22] [23] [24] [25]
 [31] [300] [33] [34] [35]
 [41] [ 42] [43] [44] [45]
You use the same syntax to assign to an element in an object’s data field. 
Continuing with the 
myMenuObj example shown in “Accessing Elements of a 
Java Array” on page 5-36, you assign to the third menu item in 
menuItemArray 
as follows.
myMenuObj.menuItemArray(3) = java.lang.String('Save As...');
Using Single Subscript Indexing for Array Assignment
You can use a single-array subscript to index into a Java array structure that 
has more than one dimension. Refer to “Using Single Subscript Indexing to 
Access Arrays” on page 5-36 for a description of this feature as used with Java 
arrays.
You can use single-subscript indexing to assign values to an array as well. The 
example below assigns a one-dimensional Java array, 
onedimArray, to a row of 
a two-dimensional Java array, 
dblArray. Start out by creating the 
one-dimensional array.
onedimArray = javaArray('java.lang.Double', 5);
for k = 1:5
 onedimArray(k) = java.lang.Double(100 * k);
 end
Since dblArray(3) refers to the 5-by-1 array displayed in the third row of 
dblArray, you can assign the entire, similarly dimensioned, 5-by-1 
onedimArray to it.
dblArray(3) = onedimArray
dblArray =
java.lang.Double[][]:
 [ 11] [ 12] [ 13] [ 14] [ 15]










