mesh
Matlab function mesh
, surf
, and surfl
plot
Example:
Matlab code:
[X,Y] = meshgrid(-8:0.5:8);
R = sqrt(X.^2 + Y.^2) + eps;
Z = sin(R)./R;
mesh(X, Y, Z, 'EdgeColor', 'black')
surf
Matlab code:
surf(X, Y, Z, 'FaceColor', 'red', 'EdgeColor', 'none');
camlight left
lighting gouraud
% view(-15,65)
Learn more examples and documentation of surface plots here.
isosurface
Visualize the surface defined by
Example:
Matlab code:
[x,y,z] = meshgrid([-3:0.25:3]);
V = (x.^2 + y.^2 + z.^2) .* exp(-x.^2 -y.^2 -z.^2);
s = isosurface(x,y,z,V,1e-4);
p = patch(s);
isonormals(x,y,z,V,p)
view(3);
set(p,'FaceColor',[0.5 1 0.5]);
set(p,'EdgeColor','none');
camlight;
lighting gouraud;
To visualize volumetric data, we have to combine several Matlab functions together: isosurface
, isonormals
, isocaps
, and patch
.
Matlab code:
[x,y,z] = meshgrid([-pi:0.25:pi]);
V = cos(x.*y.*z);
A = (V + 1) / 2;
B = 1.0 - A;
visual3d_lyx(A, B, A*0, [0.8, 0.55, 0.5], [0.6, 0.6, 0.6], [1,1,1]);
Here we use the homemade function visual3d_lyx
to do all the visualization. The function is available as a Matlab M file.