%% Specify Colormap Colors for Mesh Plot With Curtain
% Specify the colors for a mesh plot and surrounding curtain by including a fourth matrix input, C. The mesh plot uses Z for height and C for color. Specify the colors using a colormap, which uses single numbers to stand for colors on a spectrum. When you use a colormap, C is the same size as Z. Add a color bar to the graph to show how the data values in C correspond to the colors in the colormap.

[X,Y] = meshgrid(-3:.125:3);
Z = peaks(X,Y);
C = gradient(Z);
meshz(X,Y,Z,C)
colorbar

% Copyright 2015 The MathWorks, Inc.