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
Run-time or execution-time error: The Run-time, or execution-time, errors are found whenever a script or function is executing. With most of the languages, an illustration of

Rectangle - graphics objects: The other core graphics object is the rectangle that can have curvature added to it (!!). Merely calling the function rectangle without any argum

Areacirc function: The areacirc function can be called from the Command Window as shown here, or from a script. Here is a script which will prompt the user for the radius of o

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

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

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

Generic code for Reading from Files: The generic code to complete this is as shown below:   fid = fopen('filename'); if fid == -1    disp('File open not suc

Use of function polyval: The better the curve fit, the more exact these interpolated and extrapolated values will be. By using the subplot function, we can loop to display the

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

MENU Function: The MATLAB also has a built-in function known as menu which will display a figure Window with push buttons for the choices. The very first string passed to the