Structures and cell arrays
In many real life applications, we have to work with objects that are described by many different types of variables. For example, if we wish to describe the motion of a projectile, it would be useful to know its mass (a scalar), current velocity (a vector), type (a string), and so forth. In Octave, you can instantiate a single variable that contains all this information. These types of variables are named structures and cell arrays.
Structures
A structure in Octave is like a structure in C—it has a name, for example projectile, and contains a set of fields3 that each has a name, as shown in the following figure:
We can refer to the individual structure field using the.character:
structurename.fieldname
where structurename
is the name of the structure variable, and fieldname
is (as you may have guessed) the field's name.
3or members in C terminology
To show an example of a structure, we can use the projectile described above. Let us therefore name the structure variable...