Illustration of variable scope, MATLAB in Engineering

Illustration of Variable scope:

Running this function does not add any of variables to the workspace, as elaborated:

>> clear

>> who

>> disp(mysum([5 9 1]))

   15

>> who

>> 

The variables that are also defined in the Command Window cannot be used in a function.

Though, scripts (as opposite to the functions) do interact with the variables which are defined in the Command Window. For illustration, the function is changed to be a script mysummfile.

731_Variable Scope1.png

 

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







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

Write discussion on Illustration of variable scope
Your posts are moderated
Related Questions
Patch function - graphics objects: The patch function is used to generate a patch graphics object, which is made from 2-dimensional polygons. The patch is defined by its verti

Execute a exponential function program: Running the script will take up the menu as shown in the figure: Then, what happens will totally depend on which button(s) the

Passing arguments to functions: In all these functions examples faraway, at least one of the arguments was passed in the function call to be the value(s) of the equivalent inp

Gauss Elimination: The Gauss elimination technique consists of:    Generating the augmented matrix [A b]    Applying EROs to augmented matrix to obtain an upper trian

Structures: The Structures are data structures which group together values which are logically related in what are known as the fields of structure. The benefit of structures

Built-in colormaps: The MATLAB has numerous built-in colormaps which are named; the reference page on colormap shows them. Calling the function colormap without passing any ar

Basic mathematical operations: All the basic mathematical operations can be executed on symbolic expressions and variables (example, add, raise to a power, multiply, subtract,


Tracing of Square matrices: The trace of a square matrix is the addition of all the elements on the diagonal. For illustration, for the preceding matrix it is 1 + 6 + 11 + 16,

Executing a program: Running the program would be completed by typing the name of the script; this would call the other functions: >> calcandprintarea Whenever prompt