## Documentation Center |

Construct `cdata` and colormap for shaded
relief

`[cindx,cimap,clim] = shaderel(X,Y,Z,cmap)[cindx,cimap,clim] = shaderel(X,Y,Z,cmap,[azim
elev])[cindx,cimap,clim] = shaderel(X,Y,Z,cmap,[azim
elev],cmapl)[cindx,cimap,clim] = shaderel(X,Y,Z,cmap,[azim
elev],cmapl,clim)`

`[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`.

Display the `peaks` surface with a shaded colormap:

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

Was this topic helpful?