Example of Nested functions:
For illustration, the function below computes and returns the volume of a cube. Three arguments are then passed to it, for the width and length of the base of cube and height also. The outer function calls a nested function which computes and returns the area of the base of the cube. Note that it is not essential to pass the length and width to the inner function, as the scope of such variables involves the inner function.
An illustration of calling this function is shown here:
>> v = nestedvolume(3,5,7)
v =
105