How to use isocolor with you own color condition ?

2 ビュー (過去 30 日間)
Teerapong Poltue
Teerapong Poltue 2020 年 11 月 7 日
回答済み: Aghamarsh Varanasi 2020 年 11 月 10 日
I'm using a code
interval = [-3:0.1:3];
a= interval ;
b= interval;
c= interval;
[A,B,C] = meshgrid(a,b,c);
data = cos(A) + cos(B) + cos(C);
cdata = smooth3(rand(size(data)),'box',7);
p = patch(isosurface(A,B,C,data,0));
isonormals(A,B,C,data,p)
isocolors(A,B,C,cdata,p)
p.FaceColor = 'interp';
p.EdgeColor = 'none';
view(150,30)
daspect([1 1 1])
axis tight
camlight
lighting gouraud
but now the color grandient is given by random, I would like to give a gradient by k which is the function of coordinate x y z how can I do that
syms x y z
f = cos(x) + cos(y) + cos(z);
fx = diff(f,x);
fy = diff(f,y);
fz = diff(f,z);
fxx = diff(fx,x);
fxy = diff(fx,y);
fxz = diff(fx,z);
fyx = diff(fy,x);
fyy = diff(fy,y);
fyz = diff(fy,z);
fzx = diff(fz,x);
fzy = diff(fz,y);
fzz = diff(fz,z);
mat = [fxx fxy fxz fx; fyx fyy fyz fy; fzx fzy fzz fz; fx fy fz 0];
no = det(mat);
de = (fx^2 + fy^2 + fz^2)^2;
k = de/no;

回答 (1 件)

Aghamarsh Varanasi
Aghamarsh Varanasi 2020 年 11 月 10 日
Hi,
You can use the 6th argument of ‘isosurface to change the color gradient of the isosurface.
Here is an example
[x,y,z,v] = flow;
[faces,verts,colors] = isosurface(x,y,z,v,-3,x);
patch('Vertices', verts, 'Faces', faces, ...
'FaceVertexCData', colors, ...
'FaceColor','interp', ...
'edgecolor', 'interp')
view(3)
Note that as x increases, the color goes from the dark blue to the red.
For reference you can check this example

カテゴリ

Help Center および File ExchangeLighting, Transparency, and Shading についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by