Set or query camera view angle
camva returns the camera view angle setting in the current axes. The camera view angle determines the field of view of the camera. Larger angles produce a smaller view of the scene. Implement zooming by changing the camera view angle.
When the camera view angle mode is auto, the camera view angle adjusts so that the scene fills the available space in the window. If you move the camera to a different position, the camera view angle changes to maintain a view of the scene that fills the available area in the window.
Setting a camera view angle or setting the camera view angle to manual disables the MATLAB® stretch-to-fill feature (stretching of the axes to fit the window). This means setting the camera view angle to its current value,
can cause a change in the way the graph looks. See axes for more information.
Create two pushbuttons, one that zooms in and another that zooms out:
% Set the range checking in the callback statements to keep % the values for the camera view angle in the range greater % than zero and less than 180. uicontrol('Style','pushbutton',... 'String','Zoom In',... 'Position',[20 20 60 20],... 'Callback','if camva <= 1;return;else;camva(camva-1);end'); uicontrol('Style','pushbutton',... 'String','Zoom Out',... 'Position',[100 20 60 20],... 'Callback','if camva >= 179;return;else;camva(camva+1);end'); % Now create a graph to zoom in and out on: surf(peaks);