User`s guide
4 Using MWArra y Classes
public int numberOfFields()
Input Parameters
None
Example — Getting the Number of Fields in a Structure Array
Create an MWStructArray object with three fields and display the number
of fields:
int[] sdims = {1, 2};
String[] sfields = {"f1", "f2", "f3"};
MWStructArray S = new MWStructArray(sdims, sfields);
String[] str = S.fieldNames();
System.out.println("There are " + S.numberOfFields() +
" fields in this structure.");
When run, the example displays this output:
There are 3 fields in this structure.
Methods to Get and Set Data in the MWStructArray
Use these methods to get and set v alues in an object of class MWStructArray.
Method Description
“get” on
page 4-125
Returns the element at the specified offset as an Object.
“getData”
on page
4-127
Returns a one-dimensional array containing a copy of the data
in th e und erlying MATLAB array.
4-124