MATLAB Answers

What is the Order of Function Precedence in MATLAB 2019b or 2020a?

24 views (last 30 days)
Kareem Elgindy
Kareem Elgindy on 20 Jun 2020
Commented: Kareem Elgindy on 20 Jun 2020
If I put a .m file in the current directory or in MATLAB search path, and then call it from the MATLAB Command Window, would MATLAB look for certain file types (e.g. built-in functions) in certain directories first before it searches for the required file? For example, suppose I created a file and called it anything like u1 and then put u1 in the current directory or in MATLAB search path. Now, when I call u1 and say the built-in sine function sin from the Command Window, would MATLAB invoke sin faster than it would for u1?

  0 Comments

Sign in to comment.

Accepted Answer

Rik
Rik on 20 Jun 2020
I don't know what you would mean by 'faster'.

  3 Comments

Kareem Elgindy
Kareem Elgindy on 20 Jun 2020
Thanks Rik. By faster I mean in terms of the time required to invoke a function from the MATLAB Command Window. The webpage you referred to states at the very beginning that This topic explains how MATLAB® determines which function to call when multiple functions in the current scope have the same name. What about different names?
Rik
Rik on 20 Jun 2020
I would expect Matlab would search this list until it found a match for the first call, but a second call within the same function will skip that search. There is a lot of optimization happening under the hood, so the difference in timing could change within subsequent calls.

Sign in to comment.

More Answers (0)

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!