Trisurf Plots in MATLAB®
How to make Trisurf Plots in MATLAB® with Plotly.
3-D Surface Plot
Create a set of 3-D points and compute the Delaunay triangulation using the delaunay
function. Plot the surface defined by the triangulation.
[x,y] = meshgrid(1:15,1:15);
z = peaks(15);
T = delaunay(x,y);
trisurf(T,x,y,z)
fig2plotly(gcf);
Alternatively, you can create and plot a triangulation
object.
[x,y] = meshgrid(1:15,1:15);
z = peaks(15);
T = delaunay(x,y);
TO = triangulation(T,x(:),y(:),z(:));
trisurf(TO)
fig2plotly(gcf);
3-D Surface Plot of Expression
Plot the expression sin(x)+cos(y) over the default interval -5<x<5 and -5<y<5.
fsurf(@(x,y) sin(x)+cos(y))
fig2plotly(gcf);
Specify Interval of Surface Plot and Plot Piecewise Expression
Plot the piecewise expression
erf(x)+cos(y)sin(x)+cos(y)ā5<x<00<x<5
over -5<y<5.
Specify the plotting interval as the second input argument of fsurf
. When you plot multiple surfaces over different intervals in the same axes, the axis limits adjust to include all the data.
f1 = @(x,y) erf(x)+cos(y);
fsurf(f1,[-5 0 -5 5])
hold on
f2 = @(x,y) sin(x)+cos(y);
fsurf(f2,[0 5 -5 5])
hold off
fig2plotly(gcf);
Parameterized Surface Plot
Plot the parameterized surface
x=rcos(u)sin(v)y=rsin(u)sin(v)z=rcos(v)wherer=2+sin(7u+5v)
for 0<u<2Ļ and 0<v<Ļ. Add light to the surface using camlight
.
r = @(u,v) 2 + sin(7.*u + 5.*v);
funx = @(u,v) r(u,v).*cos(u).*sin(v);
funy = @(u,v) r(u,v).*sin(u).*sin(v);
funz = @(u,v) r(u,v).*cos(v);
fsurf(funx,funy,funz,[0 2*pi 0 pi])
camlight
fig2plotly(gcf);