Initializing the data structure - function, MATLAB in Engineering

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.

 

Posted Date: 10/20/2012 6:14:41 AM | Location : United States







Related Discussions:- Initializing the data structure - function, Assignment Help, Ask Question on Initializing the data structure - function, Get Answer, Expert's Help, Initializing the data structure - function Discussions

Write discussion on Initializing the data structure - function
Your posts are moderated
Related Questions
Converting between the String and Number types: The MATLAB has many functions which convert numbers to strings in which each character element is a separate digit, and vice ve

Changing Case: The MATLAB has two functions which convert strings to all uppercase letters, or all lowercase, known as the upper and lower. >> mystring = 'AbCDEfgh';

Structures: The Structures are data structures which group together values which are logically related in what are known as the fields of structure. The benefit of structures

Replacing a string - function strrep: The function strrep finds all the occurrences of a substring within the string, and substitutes them with a new substring. The order of a

I have a frequency response data. How do I convert that to state space? I am given a 6 row and 3 column data (steady state). How do i convert that to state space model?

Creating a cell array: The other method of creating a cell array is easy to assign values to particular array elements and build it up element by element. Though, as explained

Technique to creating this structure: An alternative technique of creating this structure, that is not as efficient, includes using the dot operator to refer to fields in the

Preallocating a Vector: There are necessarily two programming techniques that can be used to simulate the cumsum function. One technique is to begin with an empty vector and c

ischar function: The ischar function return the logical true if an array is a character array, or logical false if not. >> vec = 'EK127'; >> ischar(vec) ans =

Help command: The help command is used with the script rectarea, the function readlenwid, and the major function printrectarea. To see the first comment in the subfunction, as