How can I zoom in and out of 3-D plots within MATLAB?

Illustration
himanshusingh91 - 2020-08-06T10:40:32+00:00
Question: How can I zoom in and out of 3-D plots within MATLAB?

The following example allows me to zoom in a 3-D plot:     mesh(peaks) axis vis3d zoom(2) But there is no way to zoom out: zoom(-2) ??? Error using ==> set Property value must be finite and greater than zero. Error in ==> e:\matlab5\nightly\toolbox\matlab\graph2d\zoom.m On line 217 ==> set(ax,'CameraViewAngle',ncva); I cannot find a way to zoom out of my 3-D plot.

Expert Answer

Profile picture of John Michell John Michell answered . 2025-11-20

The ZOOM function works on 3-D plots, but requires that you use the functional form of ZOOM to zoom in and out. In general, if you zoom in by a factor of X, you can zoom back out using 1/X.
For example:
 
zoom(.5)

to reverse the results, use:

zoom(2)

Negative numbers (for example, -2) are not valid zoom factors.


Not satisfied with the answer ?? ASK NOW

Get a Free Consultation or a Sample Assignment Review!