Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

the problem of callback function creating a control by uicontrol function

2 vues (au cours des 30 derniers jours)
deng
deng le 7 Août 2016
Clôturé : MATLAB Answer Bot le 20 Août 2021
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

Réponses (1)

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

Cette question est clôturée.

Community Treasure Hunt

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

Start Hunting!

Translated by