Filter löschen
Filter löschen

Cannot access callbacks in an object after switching directory?

1 Ansicht (letzte 30 Tage)
I have a class with uicontrols that have callbacks. If I instantiate the class (which opens up a gui), and then switch to another directory within matlab and try to trigger one of the callbacks (i.e. loading an image through a gui callback), I get the error:
Cannot access method 'xxxx' in class 'xxxx'.
This happens even if I switch back to the original directory I was working in. Also, the callbacks work fine as long as long as I dont switch directories. Thanks,
-J

Akzeptierte Antwort

Walter Roberson
Walter Roberson am 28 Okt. 2012
I don't know why you would continue to have the problems after you switched back, but the callback routine needs to be on the MATLAB path to be found, so if you are finding it because it is in the current directory and you switch away from that directory you will have problems.
No, MATLAB does not record instantiation paths as it goes along. Having routines resolve differently when you switch directories is considered to be a feature.
  1 Kommentar
Justin
Justin am 28 Okt. 2012
The callback routine was a method written within the class definition file; I think switching paths might have messed with this. I ended up just ditching the class approach and converted the file to a simple function call with nested functions (instead of methods). This resolved the problem. Thanks,
-J

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu File Operations finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by