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

    %% Vary Surface Chart Transparency
% Create a surface and vary the transparency based on the gradient of the
% |z| data. Use a flat transparency across each surface face by setting the
% |FaceAlpha| to |'flat'|. Set the surface color to blue to show how the
% transparency varies.

% Copyright 2015 The MathWorks, Inc.


[x,y] = meshgrid(-2:.2:2);
z = x.*exp(-x.^2-y.^2);
a = gradient(z);

surf(x,y,z,'AlphaData',a,...
    'FaceAlpha','flat',...
    'FaceColor','blue')