Subfunctions, MATLAB in Engineering

Subfunctions:

Though, it is possible to have more than one function in a given M-file. For illustration, if one function calls the other, the first function would be the primary function, and the function which is termed as the subfunction. Such functions both would be stored in the similar M file-first the primary function and then the subfunction. The name of the M-file would be similar as the name of the primary function, to avoid the confusion.

To elaborate this, a program which is similar to the earlier one, but computes and prints the area of a rectangle, this is as shown here. The script, or main program, first calls a function which reads the length and width of the rectangle, and then calls the function to print results. This function calls a subfunction to compute the area.

1669_Subfunctions.png

1177_Subfunctions1.png

 

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







Related Discussions:- Subfunctions, Assignment Help, Ask Question on Subfunctions, Get Answer, Expert's Help, Subfunctions Discussions

Write discussion on Subfunctions
Your posts are moderated
Related Questions
Graphics Properties: The MATLAB uses the Handle Graphics in all its figures. All figures consist of various objects, each of which is assigned a handle. The object handle is a

Converting between the String and Number types: The MATLAB has many functions which convert numbers to strings in which each character element is a separate digit, and vice ve

Algorithm for subfunction: The algorithm for subfunction askforn is as shown:  Prompt the user for the positive integer n.  Loop to print an error message and reprom

Data structures: The Data structures are variables which store more than one value. In order to made sense to store more than one value in a variable, the values must in some

Individual structure variable: The individual structure variable for one software package may look like this: The name of the structure variable is a package; it has f

Subfunctions: Though, it is possible to have more than one function in a given M-file. For illustration, if one function calls the other, the first function would be the prima

Forward elimination: In forward elimination, we want to obtain a 0 in the a 21 position. To accomplish this, we can alter the second line in the matrix by subtracting from it

Interpolation and extrapolation: In most cases, it is desired to estimate values other than at the sampled data points. For illustration, we may want to estimate what the temp

Print from the structure: To print from the structure, a disp function will show either the whole structure or a field. >> disp(package) item_no: 123 cost: 19.99

IS Functions for Strings: There are many functions for strings, that return logical true or false. The function isletter returns the logical true when the character is a lette