www.gusucode.com > graphics 案例源码程序 matlab代码 > graphics/PlotSurfaceNormalsExample.m
%% Plot Surface Normals % Plot the surface normals of the function $z = xe^{-x^2-y^2}$. % Copyright 2015 The MathWorks, Inc. [X,Y] = meshgrid(-2:0.25:2,-1:0.2:1); Z = X.* exp(-X.^2 - Y.^2); [U,V,W] = surfnorm(X,Y,Z); figure quiver3(X,Y,Z,U,V,W,0.5) hold on surf(X,Y,Z) view(-35,45) axis([-2 2 -1 1 -.6 .6]) hold off