MATLAB: Clearing axes using created pushbutton in S-function

s-function

Hi,
I am calling a function clear in S-function which should clear the axes but It does not call the function when the button is pressed and nothing is cleared. Could anyone tell me what's wrong?
%Button:
uicontrol('Parent',m,…
'Style','pushbutton',...
'Units','normalized',...
'Position',[0.15 .15 0.7 0.2],...
'String','erase',...
'Callback',@clear);
%Clear Function:
Function clear()
cla;

Best Answer

Why not just use @cla ? You not only overwrite the VERY IMPORTANT function clear, but you disguise what you're doing. Also when you declare the function, the keyword function is case sensitive.
h = figure;
peaks;
uicontrol('Parent',h,'Style','pushbutton', 'Units','normalized',...
'Position',[0.15 .15 0.7 0.2], 'String','erase', 'Callback',@cla);