MATLAB fmesh in MATLAB®
Learn how to make 4 fmesh charts in MATLAB, then publish them to the Web with Plotly.
3-D Mesh Plot of Expression
Plot a mesh of the input sin(x)+cos(y) over the default interval -5<x<5 and -5<y<5.
fmesh(@(x,y) sin(x)+cos(y)) fig2plotly('TreatAs', 'fmesh')


Parameterized Mesh Plot
Plot the parameterized mesh
x=rcos(s)sin(t)
y=rsin(s)sin(t)
z=rcos(t)
where r=2+sin(7s+5t)
for 0<s<2π and 0<t<π. Make the mesh partially transparent using alpha
.
r = @(s,t) 2 + sin(7.*s + 5.*t); x = @(s,t) r(s,t).*cos(s).*sin(t); y = @(s,t) r(s,t).*sin(s).*sin(t); z = @(s,t) r(s,t).*cos(t); fmesh(x,y,z,[0 2*pi 0 pi]) fig2plotly('TreatAs', 'fmesh')


alpha(0.8)
Specify Interval of Mesh Plot and Plot Piecewise Input
Plot the piecewise input
erf(x)+cos(y) -5<x<0
sin(x)+cos(y) 0<x<5
over the interval -5<y<5.
Specify the plotting interval as the second argument of fmesh
. When you plot multiple inputs over different intervals in the same axes, the axis limits adjust to include all the data.
fmesh(@(x,y) erf(x)+cos(y),[-5 0 -5 5]) hold on fmesh(@(x,y) sin(x)+cos(y),[0 5 -5 5]) hold off fig2plotly('TreatAs', 'fmesh')


Specify Mesh Plot Properties
Create a mesh plot using red lines.
fmesh(@(x,y) sin(x)+cos(y),'EdgeColor','red') fig2plotly('TreatAs', 'fmesh')

