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

2 vues (au cours des 30 derniers jours)
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.

Réponse acceptée

MathWorks Support Team
MathWorks Support Team le 27 Juin 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.

Plus de réponses (0)

Catégories

En savoir plus sur Using MATLAB Projects in Simulink dans Help Center et File Exchange

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by