Borrar filtros
Borrar filtros

How to define surface color or colormap with a color matrix?

4 visualizaciones (últimos 30 días)
Rafet
Rafet el 19 de En. de 2015
Respondida: Image Analyst el 19 de En. de 2015
Hi,
I have a 3D (volume) matrix and want to plot a surface for each 2D matrix in third dimension, for example I have a matrix of size 45 by 112 by 2053 and trying to plot each of the 2053 matrix with size 45 by 112 consecutively. I use the command below:
Xq=rand(45,112);
Yq=rand(45,112);
Zq=rand(45,112);
C=rand(45,112,2053);
for i=1:size(C,3)
surf(Xq,Yq,Zq,C(:,:,i),'Facecolor','interp');
drawnow;
pause(0.1);
end
With the default colormap, jet, MATLAB plots surfaces with colors refering to values in the matrix C(:,:,i). MATLAB demonstrates the maximum value in C(:,:,i) matrix with the top color in colormap, the problem is that I want a fixed colormap which plots same color for the same values in matrix C.
For example, if C(:,:,i) matrix is;
C(:,:,29)=[1 2 3;1 2 3;1 2 3];
C(:,:,30)=[2 4 6;2 4 6;2 4 6];
theh the maximum value "3" will be demonstrated with the top color "red" in first example, but in the second example "6" will be demonstrated with "red". I want MATLAB to demonstrate the max(max(max(C(:,:,:)))) value with "red" and the others with respect to that value.
I am looking forward for any answer.
Thanks.
Rafet

Respuestas (1)

Image Analyst
Image Analyst el 19 de En. de 2015
You can use the caxis() function after you call surf() to set the top and bottom color to known, constant values instead of the values automatically determined on a plane-by-plane basis.

Categorías

Más información sobre Colormaps en Help Center y File Exchange.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by