-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathslider_animation.m
45 lines (38 loc) · 1.44 KB
/
slider_animation.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
function slider_animation
% Create a figure and axes that interacts with a slider scale. We use the
% MATLAB peaks function with slider to manipulate the surface hilles and
% valleys
f = figure('Visible', 'off');
ax = axes('Units', 'pixels');
surf(peaks)
% Create a pop-up menu
popup = uicontrol('Style', 'popup',...
'String', {'parula', 'jet', 'hsv', 'hot', 'cool', 'gray'},...
'Position', [20 340 100 50],...
'Callback', @setmap);
% Create push button
btn = uicontrol('Style', 'pushbutton', 'String', 'Clear', ...
'Position', [20 20 50 20],...
'Callback', 'cla');
% Create slider
sld = uicontrol('Style', 'slider', ...
'Min', 1, 'Max', 50, 'Value', 25, ...
'Position', [400 20 120 20],...
'Callback', @surfzlim);
% Add a text uicontrol to label the slider.
txt = uicontrol('Style', 'text', ...
'Position', [400 45 120 20],...
'String', 'Vertical Exaggeration');
% Make figure visible after adding all components
f.Visible = 'on';
% This code uses dot notation to set properties.
% Dot notation runs in R2014b and later.
% For R2014a and earlier: set (f,'Visible', 'on');
function setmap(source,event)
val = source.Value;
maps = source.String;
% For R2014a and earlier:
% val = 51 - get(source,'Value');
zlim(ax,[-val, val]);
end
end