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
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

Illustration of nested for loops and the if statements: For illustration,when the file contains: 33   -11  2  4      5   9 22     5  -7  2     11    3 the outco

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

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

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

Illustration of Indexing into vectors of structures: For illustration, the function to print the information from packages has been modified therefore in addition to the vecto

Example of Mode When no value appears more often than any other, the smallest value in the vector will be the mode of the vector. >> shortx = [2 5 1 4]; >> mode(shortx

Opening and Closing a File: The Files are opened with the fopen function. By the default, fopen function opens a file for reading. If the other mode is preferred, a permission

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

Logical Built-In Functions: There are built-in functions in the MATLAB which are useful in conjunction with vectors or matrices of all logical true or false values; two of the