MATLAB: Broken GUI: Why does the button callback code work if I copy/paste in debugger but errors in regular runtime

guiguide

I've been building/coding a GUI (using GUIDE). At some point I "forked it". That is, my Sensor_Analysis.fig & .m files are now Sensor_Analysis2.fig & .m. Some time later this thing became broken, and it makes absolutely no sense why I'm getting a (totally uninformative) error.
The way my GUI works is I have a "load files" button, and it does some calculations after files are loaded. Then I have buttons for plotting and saving. The load files callback runs with no errors, but when I subsequently click the other buttons, I get this error:
Undefined function or variable 'Sensor_Analysis_2'.
Error in
matlab.graphics.internal.figfile.FigFile/read>@(hObject,eventdata)Sensor_Analysis_2('pushbutton_plotVcurves_Callback',hObject,eventdata,guidata(hObject))
Error while evaluating UIControl Callback
If I put in a breakpoint in the editor right at the end of my load files button callback, run the code up to that point, and then simply copy the next button's code into the Matlab command window, and execute it, then it works! But as soon as I try to use the button in the GUI again, I get the error.
What's going on here?? Really mystified and frustrated.

Best Answer

Ahh I figured it out! Sorry to pollute cyberspace with possibly not very useful info, but the problem was that I was changing directory. I was trying to make it so that every time I click Load files after the first time (the program is intended to do so multiple times), that the open file dialog box starts essentially in the directory where I left off. But I didn't realize changing Matlab's directory while a program is running kills it. Should've known. I'll need to figure out a different way to accomplish what I want...