Azzera filtri
Azzera filtri

Cannot access callbacks in an object after switching directory?

1 visualizzazione (ultimi 30 giorni)
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

Risposta accettata

Walter Roberson
Walter Roberson il 28 Ott 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 Commento
Justin
Justin il 28 Ott 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

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su File Operations in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by