MATLAB: Help required using colormap function in matlab

matlab plots

Hello Everyone,
I am using surf function to plot a 2D matrix Z. The matrix has 61 rows and 98 columns. The data varies from 26.5 to 33.5 , and in few places I have some zeros. Till now i was using the default colourmap for plotting my data using surf command. But now I want more control over the colour pattern. I was reading through the documentation of colormap. It says that
"Specify an array of color data that is equal in size to the z- data and is used for indexed colors"
I create a matrix C of same size as Z but I still did not understand what values to put so that I can use the surf function as
figure(),surf(Z,C)

Best Answer

It is not clear what you are trying to do. In the simplest case you might be trying to do
Z = 7*rand(61,98)+26.5;
C = ndgrid(1:size(Z,1), 1:size(Z,2));
but I suspect you are trying to change the colormap
set(gcf, 'ColorMap', [1:64; 64:-1:1; [32:-1:1, 64:-1:33]]'/64)
colorbar