initializing the data structure -


Initializing the data structure - Function:

Function is shown as:

 

>> printcylvols(cyls)

Cylinder x has a volume of 169.6

Cylinder a has a volume of 100.5

Cylinder c has a volume of 169.6

 

Note that in the whole data structure, cyls, is passed into the function. The function loops through each and every element, where each is a structure. It prints the code field for each, that is given by the cyls(i) code. In order to compute the volume of cylinder, the radius and height are only required, so instead of passing the whole structure to the subfunction cylvol (that would be cyls(i)), only the dimensions field is passed. The function then receives the dimensions structure as an input argument, and uses a dot operator to refer  the rad and height fields within it.

 

Request for Solution File

Ask an Expert for Answer!!
Applications of MATLAB: initializing the data structure -
Reference No:- TGS0175115

Expected delivery within 24 Hours