필터 지우기
필터 지우기

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

조회 수: 4 (최근 30일)
Rafet
Rafet 2015년 1월 19일
답변: Image Analyst 2015년 1월 19일
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

답변 (1개)

Image Analyst
Image Analyst 2015년 1월 19일
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.

카테고리

Help CenterFile Exchange에서 Colormaps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by