Why does MATLAB select the wrong function or model if I have more than one function with the same name?

8 views (last 30 days)
Why does MATLAB select the wrong function or model if I have more than one function with the same name?
If I overload a function or model name, MATLAB sometimes selects the wrong one. This even happens if I am in the directory containing the model or function that I want to run.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 27 Jun 2009
This results from the way MATLAB searches for files. If you have more than one file, or model with the same name, MATLAB will always load the one that is nearest the top of your path list.
The way around this is:
- Make sure your models/functions have different names (recommended), or
- Place the path of the model/function needed above the path of the overloaded model/function
- Change to the directory where the model/function you want is placed.
To see your path listing type 'path' at the MATLAB prompt.
To see all the listings of a specific model or function name, type
which -all modelname
where 'modelname' is the name of your model or function without the suffix .mdl or .m.

More Answers (0)

Categories

Find more on Simulink Environment Customization in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!