Info

此问题已关闭。 请重新打开它进行编辑或回答。

the problem of callback function creating a control by uicontrol function

2 次查看(过去 30 天)
if true
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
global aryData
scrsz = get(0,'ScreenSize') %获取显示器屏幕尺寸
f_size= [scrsz(3)/15 0.2*scrsz(4) 0.6*scrsz(3) 0.7*scrsz(4)]
hf=figure('Name','图1','Position',f_size);
set(hf,'NumberTitle','off') %隐藏数字标题即左上角的“Figure1,2..”
set(hf,'NumberTitle','on') %显示数字标题
set(hf,'Menubar','No') %隐藏菜单栏
set(hf,'Menubar','Figure')%显示菜单栏
hb = uicontrol(hf, 'style', 'pushbutton', ...
'units', 'normalized', ...
'position', [0.75,0.8,0.2,0.1], ...
'string', '对比',...
'Callback', @pbCompare);
%%%%-----------------------------------------
function pbCompare
global aryData
global totalTimes
msgbox('sucess')
disp 'sucess'
%%------------------------------------
end
pbCompare callback function cannot be performed. why? think you very muchu. email:dengshuaiqi@163.com

回答(1 个)

Walter Roberson
Walter Roberson 2016-8-7
Callbacks must accept at least two arguments. They can ignore them but they must accept them. You can use varargin for this purpose.

此问题已关闭。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by