Your problem is that you keep recreating the entire plot anew every time you call surf
in your loop, thus discarding any previous changes you made to the axes limits, etc. When animating plots, it's much more efficient (and easier to control the axes settings) if you use set
to update graphics objects instead of completely reproducing them, as illustrated here.
Here's a better approach to create the animation you want:
% Initialize data:
x = linspace(-2*pi, 2*pi, 100);
y = linspace(-2*pi, 2*pi, 100);
[X, Y] = meshgrid(x, y);
Z = sin(sqrt(X.^2 + Y.^2)) ./ (X.^2 + Y.^2);
% Create plot objects and set axes settings:
hSurf = surf(X, Y, Z);
view(90, 25);
xlim([-10 10]);
ylim([-10 10]);
zlim([-1 1]);
% The animation loop:
for t = linspace(0, 2*pi, 400)
Z = sin(sqrt(X.^2 + Y.^2 + t)) ./ (X.^2 + Y.^2 + t); % Recalculate Z
set(hSurf, 'ZData', Z); % Update surface Z data
pause(0.01); % Pause/refresh plot
end