www.gusucode.com > graphics 案例源码程序 matlab代码 > graphics/DisplayContourLabelsExample.m

    %% Display Contour Labels
% Set up matrices |X|, |Y|, and |Z|. Create a contour plot and display the
% contour labels by setting the |ShowText| property to |on|.

% Copyright 2015 The MathWorks, Inc.


x = -2:0.2:2;
y = -2:0.2:3;
[X,Y] = meshgrid(x,y);
Z = X.*exp(-X.^2-Y.^2);

figure
contour(X,Y,Z,'ShowText','on')