フィルターのクリア

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 Center および File ExchangeColormaps についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by