Here is an example that demonstrates how to create a colormap that falls within a particular range.
h = mesh(peaks);
C = get(h,'ZData');
i1 = find(C<=-2);
i2 = find(C>-2 & C<=4);
i3 = find(C>4);
C(i1) = 1 + 0*i1;
C(i2) = 2 + 0*i2;
C(i3) = 3 + 0*i3;
set(h,'CData',C,'CDataMapping','direct');
colormap([.5 .5 .5; 1 0 0; 0 0 1])
The FIND command was used to find the Z values that were in the range that I wanted. Type 'help find' (without the quotes) at the MATLAB command prompt for more information.
The above example uses the Surface property CDataMapping. Here is more information taken from the HelpDesk.
CDataMapping: [ {direct} | scaled ]
Direct or scaled color mapping. This property determines how MATLAB interprets indexed color data used to color the Surface. (If you use true color specification for CData, this property has no effect.)
scaled - transform the color data to span the portion of the colormap indicated by the Axes CLim property, linearly mapping data values to colors. See the caxis reference page for more information on this mapping.
direct - use the color data as indices directly into the colormap. The color data should then be integer values ranging from 1 to length(colormap). MATLAB maps values less than 1 to the first color in the colormap, and values greater than length(colormap) to the last color in the colormap. Values with a decimal portion are fixed to the nearest, lower integer.