Vous suivez désormais cette question
- Les mises à jour seront visibles dans votre flux de contenu suivi.
- Selon vos préférences en matière de communication il est possible que vous receviez des e-mails.
Method is not defined or is removed from MATLAB search path
14 commentaires
- there's never any need to cd into anything, thus the current folder shouldn't change
- you shouldn't rely on the current folder, instead the class folder should be on the path
- When doCoolStuff.m is inside the ourTools/@doCoolStuff folder (method folder), it gets overshadowed by the one in theirTools, even though theirTools is lower on the path than ourTools.
- When doCoolStuff.m is inside the ourTools/doCoolStuff folder (regular folder on path), both the class and method files are found using which(), but the error mentioned in my post above occurs, indicating that the associated methods were not found when trying to actually call the function.
- I've been using the same class, methods, and matlab path for months with no issues. The only potential difference this time was that I was running another MATLAB instance in the background in the same working directory as the one in which I was seeing this problem
- Methods defined within MyClass.m are working just fine
- Matlab IS able to auto-complete the names of the class methods that it supposedly can't find. Ie, typing instance.myEx and hitting tab correctly auto-completes to instance.myExternalMethod
- Examining the path variable shows nothing amiss. The directory containing @MyClass is on the path, and there doesnt seem to be anything on the path that might be confounding things
- Performing which('MyClass') shows what I'd expect: \\server1\...\@MyClass\MyClass.m % MyClass constructor
- Performing which('myExternalMethod') shows: \\server1\...\@MyClass\MyClass.m % MyClass method (note: there is a method stub of myExternalMethod in MyClass.m)
- Since the which() call on the external method returned MyClass.m instead of @MyClass/myExternalMethod.m, I wanted to see what would happen if I commented out the function definition stub in MyClass.m. That is, MyClass.m contains the line "myExternalMethod(obj)", and I commented this out
- After that, the call to which('myExternalMethod') showed: \\server1\...\@MyClass\myExternalMethod.m as I might expect
- And now, suddenly, everything was working again. I could call instance.myExternalMethod() without throwing an error.
- I then un-commented the function stub, reverting the file to its original state, and everything was still working fine. So essentially the issue fixed itself somehow. All of the other external methods also started working (they had all been causing the same error).
- /parentFolder/myClass.m
- /parentFolder/@myClass/foo1.m
- /parentFolder/@myClass/myClass.m
- /parentFolder/@myClass/foo1.m
Réponses (0)
Voir également
Catégories
Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!Une erreur s'est produite
Impossible de terminer l’action en raison de modifications de la page. Rechargez la page pour voir sa mise à jour.
Sélectionner un site web
Choisissez un site web pour accéder au contenu traduit dans votre langue (lorsqu'il est disponible) et voir les événements et les offres locales. D’après votre position, nous vous recommandons de sélectionner la région suivante : .
Vous pouvez également sélectionner un site web dans la liste suivante :
Comment optimiser les performances du site
Pour optimiser les performances du site, sélectionnez la région Chine (en chinois ou en anglais). Les sites de MathWorks pour les autres pays ne sont pas optimisés pour les visites provenant de votre région.
Amériques
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
Asie-Pacifique
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)