Example of functions which return values, MATLAB in Statistics

Example of Functions which return values:

Calling this function prints the circumference, since there is no way to store the value, hence, it can be used in following computations:

>> calccircum1(3.3)

   20.7345

As no value is returned by the function, it would be an error to attempt to store the value in a variable:

>> c = calccircum1(3.3)

??? Error using ==> calccircum1

Too many output arguments.

By dissimilarity, the function below computes and returns the circumference, and hence, it can stored and used in other computations. For illustration, if the circle is the base of a cylinder, and we wish to compute the surface area of the cylinder, we would require to multiply the result from the calccircum2 function by the height of the cylinder.

312_Example of Functions which return values.png

>> circumference = calccircum2(3.3)

circumference =

   20.7345

>> height = 4;

>> surf_area = circumference * height

surf_area =

   82.9380

Posted Date: 10/19/2012 8:06:09 AM | Location : United States







Related Discussions:- Example of functions which return values, Assignment Help, Ask Question on Example of functions which return values, Get Answer, Expert's Help, Example of functions which return values Discussions

Write discussion on Example of functions which return values
Your posts are moderated
Related Questions
bjjh

Illustration of Input in a for loop: In this illustration, the loop variable iv iterates through the values 1 through 3, therefore the action is repeated three times. The acti

Representing Logical true and False: It has been stated that expressions which are theoretically true really have the integer value of 1, and expressions which are theoretical

Advanced File Input and Output: In that section, we saw how to read the values entered by user using the input as well as the output functions disp and fprintf, that shows inf

Polynomials: Simple curves are polynomials of various degrees, or orders. The degree is the integer of the highest exponent in the expression. The illustrations are as follows

Vectorizing: In most of the cases in MATLAB, loops are not essential. As MATLAB is written specifically to work with the vectors and matrices, most operations can be completed

Index vector: The index vector is then used as the indices for original vector. To get grades vector in ascending order, the indices used would be grades (2), grades (5), and

WHILE Loops: The while statement is used as a conditional loop in MATLAB; it is used to repeat an action whenever ahead of the time it is not known how many times the action w

Data structure layers: There are many layers in this variable. For illustration,  cyls is the whole data structure, that is a vector of structs  cyls(1) is a separate

Debugging Techniques: Any error in the computer program is called a bug. This word is thought to date back to the 1940s, whenever a problem with an early computer was found to