How to use isocolor with you own color condition ?
2 次查看(过去 30 天)
显示 更早的评论
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;
0 个评论
回答(1 个)
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
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Lighting, Transparency, and Shading 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!