MATLAB REAL-TIME WORKSHOP 7 - TARGET LANGUAGE COMPILER Uživatelský manuál Strana 223

  • Stažení
  • Přidat do mých příruček
  • Tisk
  • Strana
    / 408
  • Tabulka s obsahem
  • KNIHY
  • Hodnocené. / 5. Na základě hodnocení zákazníků
Zobrazit stránku 222
Passing Data to a Java Method
5-53
Handling a Cell Array of Java Objects
You create a cell array of Java objects by using the MATLAB syntax
{a1,a2,...}. You index into a cell array of Java objects in the usual way, with
the syntax
a{m,n,...}.
The following example creates a cell array of two
Frame objects, frame1 and
frame2, and assigns it to variable frames.
frame1 = java.awt.Frame('Frame A');
frame2 = java.awt.Frame('Frame B');
frameArray = {frame1, frame2}
frameArray =
[1x1 java.awt.Frame] [1x1 java.awt.Frame]
The next statement assigns element {1,2} of the cell array frameArray to
variable
f.
f = frameArray {1,2}
f =
java.awt.Frame[frame2,0,0,0x0,invalid,hidden,layout =
java.awt.BorderLayout,resizable,title=Frame B]
Other Data Conversion Topics
There are several remaining items of interest regarding the way MATLAB
converts its data to a compatible Java type. This includes how MATLAB
matches array dimensions, and how it handles empty matrices and empty
strings.
How Array Dimensions Affect Conversion
The term dimension, as used in this section, refers more to the number of
subscripts required to address the elements of an array than to its length,
width, and height characteristics. For example, a 5-by-1 array is referred to as
having one dimension, as its individual elements can be indexed into using only
one array subscript.
In converting MATLAB to Java arrays, MATLAB handles dimension in a
special manner. For a MATLAB array, dimension can be considered as the
number of nonsingleton dimensions in the array. For example, a 10-by-1 array
has dimension 1, and a 1-by-1 array has dimension 0. In Java, dimension is
Zobrazit stránku 222
1 2 ... 218 219 220 221 222 223 224 225 226 227 228 ... 407 408

Komentáře k této Příručce

Žádné komentáře