MATLAB Examples

This is an example of how to create a mesh plot from a function in MATLAB®.

Read about the fmesh function in the MATLAB documentation. This function is available in R2016a or newer.

For more examples, go to MATLAB Plot Gallery

% Check version
if verLessThan('matlab','9.0')
    error(['fmesh is available in R2016a or newer. ', ...
        'For older releases, use ezmesh instead.'])
end

% Create the mesh plot using the function f(x,y) = y^2 - x^2
figure
fmesh(@(x,y) y.^2 - x.^2, [-3 3 -3 3])

% Add labels and title
xlabel('x')
ylabel('y')
zlabel('z')
title('f(x,y) = y^2 - x^2')