Hello everyone. I am writing a GUI as an app for a particular control application. I am using the normal class definition structure, defining my class with properties and then methods. This method is new to me in Matlab, but I believe I have done it correctly. However, when I try to set the Callback property for one of my UI controls and then evaluate the Callback, I get the following error:
%Undefined function 'COM_port_Callback' for input arguments of type 'matlab.ui.control.UIControl'.
Here are what I believe to be the two relevant sections of my code. I am writing this GUI without GUIDE and I felt no need to have a CreateFCN since nothing needed to execute upon creation. Avoiding this worked for other GUIS I have built, but if there is something special about doing it with the specifically defined class structure, then I would appreciate it if someone could provide input.
Here is my initialization of the UI element:
app.COM_port = uicontrol('Parent',app.panel2,'Style','edit',... 'Position',[90,68,50,20],... 'Units','normalized',... 'Callback',@COM_port_Callback,... 'FontUnits','normalized');
Furthermore, here is my callback function:
function COM_port_Callback(app,hObject,eventdata) COM = str2num(get(app.COM_port,'String'));
I am unsure why the error is returned, and I would very much appreciate any input. By the way, both COM_Port and COM are initialized in the Properties section of my Class, so I don't believe that is the issue. Thank you for your help guys!
Best Answer