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
Sorting Vectors of structures: Whenever working with vector of structures, it is very common to sort based on a particular field within the structures. For illustration, recal

Scaling:   change a row by multiplying it by a non-zero scalar sri →  ri For illustration, for the matrix:

Execution steps: Whenever the program is executed, the steps below will take place: The script calcandprintarea starts executing. The calcandprintarea calls the readr

Example of Plotting from a Function: For illustration, the function can be called as shown below:      >> y = [1:2:9].^3      y =     1  27  125  343  729

Binary Search: The binary search supposes that the vector has been sorted first. The algorithm is just similar to the way it works whenever looking for a name in a phone direc

For Loops which do not use an iterator Variable in the action: In all the illustrations that we seen so far, the value of the loop variable has been used in same way in the ac

Write a program to examine exponential function: We will write a program to examine the value of e and the exponential function. It will be a menu-driven. The menu options wil

Sound Files: The sound signal is an illustration of a continuous signal which is sampled to result in a discrete signal. In this situation, sound waves traveling through the a

Illustration of gauss-jordan: Here's an illustration of performing such substitutions by using MATLAB >> a = [1 3 0; 2 1 3; 4 2 3] a = 1 3 0 2 1 3 4 2

Illustration of gauss-jordan elimination: An illustration of interchanging rows would be r1 ¬→ r3, that would results: Now, beginning with this matrix, an illustration of sc