function ex_uicontrol
% Example code for uicontrol reference page
% Creates a slider. Found on Matlab tutorial
% Create a figure and an axes to contain a 3-D surface plot.
figure;
hax = axes('Units','pixels');
surf(peaks);
% Create a uicontrol object to let users change the colormap
uicontrol('Style', 'slider',...
'Min',1,'Max',50,'Value',41,...
'Position', [400 20 120 20],...
'Callback', {@surfzlim,hax}); % Slider function handle callback
% Implemented as a subfunction
% Add a text uicontrol to label the slider.
uicontrol('Style','text',...
'Position',[400 45 120 20],...
'String','Vertical Exaggeration')
end
function surfzlim(hObj,event,ax) %#ok
% Called to set zlim of surface in figure axes
% when user moves the slider control
val = get(hObj,'Value');
surf(val*peaks);
zlim(ax,'auto');%[-val val]);
end
|
|