我做了一个快速测试函数来测试 guidata,但是每当我使用 but3c 时,我都会不断收到“输入参数不足”的错误。
有人愿意帮忙吗?
function test
clear
clc
figure();
but1 = uicontrol('units','normalized','position',[0.2,0.2,0.2,0.2],...
'callback',@but1cb);
but2 = uicontrol('units','normalized','position',[0.6,0.6,0.2,0.2],...
'callback',@but2cb);
but3 = uicontrol('units','normalized','position',[0.4,0.4,0.2,0.2],...
'callback',@but3cb,'string',' ');
function but1cb(hObject,~,handles)
a = 1;
handles.a = 1;
guidata(hObject, handles)
end
function but2cb(hObject,~,handles)
a = 2;
handles.a = 2;
guidata(hObject, handles)
end
function but3cb(hObject,~,handles)
a = handles.a
print(a);
end
end