Construct cdata and colormap for shaded relief

## Description

[cindx,cimap,clim] = shaderel(X,Y,Z,cmap) constructs the colormap and color indices to allow a surface to be displayed in colored shaded relief. The colors are proportional to the magnitude of Z, but modified by shades of gray based on the surface normals to simulate surface lighting. This representation allows both large and small-scale differences to be seen. X, Y, and Z define the surface. cmap is the colormap used to create the new shaded colormap cimap. cindx is a matrix of color indices to cimap, based on the elevation and surface normal of the Z matrix element. clim contains the color axis limits.

[cindx,cimap,clim] = shaderel(X,Y,Z,cmap,[azim elev]) places the light at the specified azimuth and elevation. By default, the direction of the light is East (90º azimuth) at an elevation of 45º.

[cindx,cimap,clim] = shaderel(X,Y,Z,cmap,[azim elev],cmapl) chooses the number of grays to give a cimap of length cmapl. By default, the number of grayscales is chosen to keep the shaded colormap below 256. If the vector of azimuth and elevation is empty, the default locations are used.

[cindx,cimap,clim] = shaderel(X,Y,Z,cmap,[azim elev],cmapl,clim) uses the color limits to index Z into cmap.

## Examples

Display the peaks surface with a shaded colormap:

[X,Y,Z] = peaks(100);
cmap = hot(16);
surf(X,Y,Z,cindx); colormap(cimap); caxis(clim)

## Tips

This function effectively multiplies two colormaps, one with color based on elevation, the other with a grayscale based on the slope of the surface, to create a new colormap. This produces an effect similar to using a light on a surface, but with all of the visible colors actually in the colormap. Lighting calculations are performed on the unprojected data.