Class Constructors

Whenever, the name of function matches that of a class constructor function, the precedence will always be given to the class constructor, irrespective of the user defined function’s precedence.

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. 

Similar Reads

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....

Imported Functions

...

Nested Functions

After the variable names, when a locally defined function matches the name of an explicitly imported function, MATLAB will always use the imported function for the given name....

Local Functions

...

Private Functions

After imported functions, precedence is given to the nested functions within the parent function i.e, in a function, the nested functions are given precedence in call order. In other words, a nested function is called before its parent function....

Object Functions

After nested functions, MATLAB gives precedence to local functions declared in a file. Thus, so far, we have the following order....

Class Constructors

After the locally defined functions, the precedence comes to private functions. A private function in MATLAB is a function that is stored in a subfolder named private, to limit the scope of that particular function. We shall not discuss the creation of private functions as it is not in this article’s scope....

Simulink Models

The next precedence is given to an object function, which is a function that takes a specified class of objects as input arguments.  Whenever, there are multiple object functions with same name, MATLAB gives precedence according to the list of input class objects....

Functions in different paths

Whenever, the name of function matches that of a class constructor function, the precedence will always be given to the class constructor, irrespective of the user defined function’s precedence....

Precedence of functions in same folder

In many MATLAB applications, there is a required to load some SIMULINK models, such as signal processing. In case there is a conflict with the name of local functions and a loaded SIMULINK model’s function, the precedence will be given to local function....

Conclusions

Lastly, MATLAB gives precedence to functions defined in the current folder over any other function defined elsewhere on path....