Clear Filters
Clear Filters

Info

This question is closed. Reopen it to edit or answer.

the problem of callback function creating a control by uicontrol function

2 views (last 30 days)
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

Answers (1)

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

This question is closed.

Community Treasure Hunt

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

Start Hunting!