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
Need of a nested loop: How would we sum each individual column, rather than getting an overall sum? Answer: The programming technique would need a nested loop in whi

Functions which complete a task without returning Values: Most of the functions do not compute values, but instead of accomplish a task like printing formatted output. As thes

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

Steps for input output functions - Lower level file: The steps involved are as shown below:  Open the file.  Read the file, write to the file, or append to the file.

Sequential Search: A sequential search is completed by looping through the vector element-by-element starting from the beginning, looking for the key. Usually the index of the

Variable packages: Variable packages are now the vector of structures, hence each and every element in the vector is a structure. To show one element in the vector, an index i

Example of Function stubs: The three functions have not so far been written, though, therefore the function stubs are put in place so that the script can be executed and teste

Roots function - Polynomials: The roots function in MATLAB is used to find the roots of an equation represented by a polynomial. For illustration, for the mathematical functio

Function Stubs: The other common debugging method, which is used when there is a script main program which calls many functions, is to use the function stubs. A function stub

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 computat