Variables Functions
In a case where the user defines a variable with the same name as a function, MATLAB will never call the function until the variable is deleted from memory. See the example below.
Matlab
% function function geeks(x) disp(x) end |
The above is a function that prints the passed parameter. Now, when we declare a variable with same name in current workspace, and then call the function, it will throw an error, saying that there is a variable and function with same name, kindly clear the variable it was unintentional.
Output:
Thus, a variable gets precedence over a function with the same name.
Function Precedence Order in MATLAB
In this article, we shall discuss the function precedence order in MATLAB. The first thing to keep in mind is that the order explained below is defined for an individual scope (current workspace); it does not hold when there are multiple workspaces in play.
Now, let us explore the order individually.