This is a continuation of Matlab: Lorentz Attractor, however, these methods can be applied to any line plot or collection of points.
A slightly more aesthetically pleasing representation of the Lorentz Attractor can be achieved by adding axis off
. And altering the view’s azimuth and elevation: view(15, 48)
.
Now we’re talking. Let’s say I want to make a surface or mesh from this dandy line plot. Using surf
or mesh
will throw an error, since x, y, and z are all 1D vectors! Whatever shall we do!
Never fear, mathematicians will save the day.
Delaunay created a sweet method of triangulating points. If we treat this line plot as a collection of points, we can triangulate to find an approximate surface.
tri = delaunay(x,y);
plot(x,y,'.')
%determine amount of triangles
[r,c] = size(tri);
disp(r)
%plot with trisurf
h = trimesh(tri, x, y, z, 'FaceAlpha', 0.6);
alpha = 0.4
view(15, 48)
axis vis3d
axis off
l = light('Position',[-50 -15 29])
lighting phong
shading interp
What if we’d like a surface instead of the mesh? Then we’ll change trimesh
to trisurf
add transparency (alpha = 0.7
) and find: