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
Forward elimination: In forward elimination, we want to obtain a 0 in the a 21 position. To accomplish this, we can alter the second line in the matrix by subtracting from it

. Generate the following signal, x(n)=1+cos((25*pi*n)/100),0 Compute the DTFT of x[n] for w=0:0.01:2*pi Plot the Real part, imaginary part, the amplitude and phas

readlenwid function: function call: [length, width] = readlenwid; function header: function [l,w] = readlenwid In the function call, not any argument is passed; henc

Example of file ploting data: As the other example, a data file called 'compsales.dat' stores the sales figures (in millions) for divisions in a company. Each line in the f

Implementation of binary search: The binary search can be implemented as a recursive function. The recursive function below also implements this binary search algorithm. It re

Gauss, Gauss-Jordan elimination: For 2 × 2 systems of equations, there are well-defined, easy solution techniques. Though, for the larger systems of equations, finding solutio

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 =

Simplification Functions: There are numerous functions which work with expressions, and simplify the terms. Not all the expressions can be simplified, but the simplify functio

Function rmfield - structure: The function rmfield eliminates a field from the structure. It returns a new structure with field eliminated, but does not modify the original st

Illustration of Sound files: For illustration, the following script generates a subplot which shows the signals from chirp and from train, which is as shown in figure: