UI Callback error when writing a GUI as an app?
显示 更早的评论
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!
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Interactive Control and Callbacks 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!