MATLAB: The cause of ‘Error while evaluating uicontrol Callback’ in GUI window

guiguidehandlesMATLAB

I have encountered this error in running a GUI window that I have created. From what I have been able to discern online, it is caused by a problem with the handle structure but the piece of code that continues to be identified by matlab as the problem is this:
Error in new_window_2>pushbutton1_Callback (line 190)
set(handles.verticalBin, 'enable', 'on');
I have changed a number of lines in the code but i am not sure how this (or other set(handles, 'enable', '') statements) are causing an error. How might the handles structure be failing to work properly to generate this error?

Best Answer

Using globals is a really bad idea. This impedes the debugging, because you cannot find reliable, which code is resposnible for the last change. Do not use such an indirect method, but the handles struct, which is used for sharing other details already.
It is not clear, where the object of the handle handles.verticalBin is created. Are you sure that this field is existing in the handles struct?
Related Question