How to use isocolor with you own color condition ?
4 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Aghamarsh Varanasi
am 10 Nov. 2020
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 Kommentare
Siehe auch
Kategorien
Mehr zu Lighting, Transparency, and Shading finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!