How to Setting Custom Colours in 4D figures (Slice Function)?

7 ビュー (過去 30 日間)
changkun
changkun 2013 年 12 月 23 日
編集済み: Sean de Wolski 2014 年 1 月 7 日
[x,y,z] = meshgrid(-2:.2:2,-2:.25:2,-2:.16:2);
v = x.*exp(-x.^2-y.^2-z.^2);
xslice = [-1.2,.8,2]; yslice = 2; zslice = [-2,0];
slice(x,y,z,v,xslice,yslice,zslice)
I want to change the colour according the value of v.

採用された回答

Sean de Wolski
Sean de Wolski 2013 年 12 月 23 日
編集済み: Sean de Wolski 2014 年 1 月 7 日
The color right now is changed according to v...
That's why the color in the middle shows up.
More per clarification
Build another array, C, that will be an index into the colormap:
[x,y,z] = meshgrid(-2:.2:2,-2:.25:2,-2:.16:2);
v = x.*exp(-x.^2-y.^2-z.^2);
xslice = [-1.2,.8,2]; yslice = 2; zslice = [-2,0];
%
%v<0, blue; 0<=v<0.2, green; 0.2<=v, red.
%
C = ones(size(v)); %blue
C((v > 0) & (v < 0.2)) = 2; %green
C(v>=0.2) = 3; %red
colormap([0 0 1;0 1 0;1 0 0]); %bgr
slice(x,y,z,C,xslice,yslice,zslice)
  2 件のコメント
changkun
changkun 2014 年 1 月 2 日
Thank you! It's me that described not accurately.
I'd like to set up like this.
v<0, blue; 0<=v<0.2, green; 0.2<=v, red.
How to realize it? Thanks!
Sean de Wolski
Sean de Wolski 2014 年 1 月 7 日
See More

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by