Individual structure variable:
The individual structure variable for one software package may look like this:
![1047_Individual structure variable.png](https://www.expertsmind.com/CMSImages/1047_Individual%20structure%20variable.png)
The name of the structure variable is a package; it has four fields that are: item_no, cost, price, and code.
The one way to initialize the structure variable is to use struct function that preallocates the structure. The field names are passed to struct in the quotes, following every one with the value for that field:
>> package = struct('item_no',123,'cost',19.99,. . .
'price',39.95,'code','g')
package =
item_no: 123
cost: 19.9900
price: 39.9500
code: 'g'
Typing the name of structure variable will show the names and contents of all the fields:
>> package
package =
item_no: 123
cost: 19.9900
price: 39.9500
code: 'g'
Note that in the Workspace Window, the variable package is scheduled as 1 × 1 struct. The MATLAB, as it is written to work with the arrays, supposes that the array format.Merely as a single number is treated as 1 × 1 double, a single structure is considered as a 1 × 1 struct.