且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

MATLAB GUI错误对不存在的字段的引用' ---'

更新时间:2022-03-22 03:20:41

当您将 S 添加到回调中时,作为附加输入参数 S 不包含字段 eth_xegim eth_yegim 尚未添加到结构中.在添加字段后定义回调:

At the time you add S to the callback as an additional input argument S does not contain the fields eth_xegim and eth_yegim as they have not been added to the structure. Define the callbacks after fields have been added:

S.eth_xegim = uicontrol(S.ph_arazi,'Style','edit','String','0',...
    'HorizontalAlignment','right','BackgroundColor','w',...
    'Position',[250 68 40 18]);

S.eth_yegim = uicontrol(S.ph_arazi,'Style','edit',...
    'String','0','HorizontalAlignment','right',...
    'BackgroundColor','w','Position',[250 40 40 18]);


S.eth_xegim.Callback = {@errmsg,S};
S.eth_yegim.Callback = {@errmsg,S};