Illustration of nested function, MATLAB in Mathematics

Illustration of nested function:

The output arguments are distinct from variables. The scope of an output argument is merely the nested function; and it cannot be used in the outer function. In this illustration, the outbase is used only in the base function; its value, for illustration, could not be printed from the nestedvolume.

If a variable is not used in an outer function, then the variable is also local to the nested function. The earlier illustration has been modified to elaborate these scope rules. In the illustration below, the value of the output argument outbase cannot be used by the function nestedvolume2 (as it is an output argument, not a variable). The variable bvar is also local to the function base as it is never used in the nestedvolume2. On other hand, the cvar is used by nestedvolume2; therefore its scope is the workspace of nestedvolume2-meaning, for illustration, which it can be printed by printstuff.

1243_Illustration of nested function.png

An illustration of calling this modified function is shown here:

>> nestedvolume2(3,5,7)

This function computes a volume

outvol is 105.0

cvar is 15.0

outvol is 105.0

cvar is 15.0

ans =

  105

Posted Date: 10/22/2012 1:26:33 AM | Location : United States







Related Discussions:- Illustration of nested function, Assignment Help, Ask Question on Illustration of nested function, Get Answer, Expert's Help, Illustration of nested function Discussions

Write discussion on Illustration of nested function
Your posts are moderated
Related Questions
Customizing Plots : There are numerous ways to customize figures in the Figure Window. On clicking the Plot Tools icon will bring up the Property Editor & Plot Browser, with ma

Strings as Vectors: The Strings are considered as vectors of characters-or in another words, a vector in which each and every element is a single character-so numerous vector

Minimum and Maximum Value The MATLAB has built-in functions for numerous statistics. For illustration, min and max to find the minimum or maximum value in a data set. >> x

Pie chart - plot functions: The MATLAB also has a function pie which will generate a pie chart. Calling the function with the form pie (vec) draws a pie chart, by using the pe

Plot Functions: Faraway, we have plotted to generate two-dimensional plots and bar to generate bar charts. We have seen how to clear the Figure Window by using clf, and how to

Applications of Customized Strings: Labels, Prompts, Arguments to Functions: The one of very useful application of this is to involve numbers in strings that are used to plot

Using Functions with the Vectors and Matrices: As MATLAB is written to work with the vectors and matrices, the whole vector or matrix can be passed as an argument to the funct

Illustration of Spreadsheet Files: This reads the numbers in a double vector variable nums and the text in a cell array txt (the xlsread function forever returns the numbers f

Creating string Variables: The string consists of a few numbers of characters (including, possibly, none). These are the illustrations of the strings: '' 'x' 'ca

Use of logical vector: Determine how many elements in the vector vec were greater than 5, the sum function can be used on the resulting vector isg: >> sum(isg) ans =