%% 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.

[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')

% Copyright 2015 The MathWorks, Inc.