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
Illustration of Customizing plots: Illustration, the bar and barh functions by the default place a width of 0.8 between bars. Whenever called as bar(x,y), the width of 0.8 is

Properties of the text box - graphics objects: By using get will show properties of the text box, the illustration is as shown below: >> get(thand)   BackgroundColor

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

Illustration of Median When the vector is not in sorted order to start with, the median function will still return the right answer (it will sort the vector automatically). For

Illustration of Mode When there is more than one value with similar (highest) frequency, then the smaller value is mode. In the case below, as 3 and 8 appear twice in the vecto

Execution of persistent variables: The functions can also be called from the script or from the Command Window, as shown here. For illustration, the functions are called first

Lower Level File I/O Functions: Whenever reading from data file, as long as the data in the file is "regular" the load function works-in another words, the similar type of dat

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

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

Nested Functions: We have seen that the loops can be nested, that means that one inside of the other, functions can be nested. The terminology for nested functions is that an