MATLAB Examples

This is an example of how to create a surface plot in MATLAB®.

Read about the surf function in the MATLAB documentation.

For more examples, go to MATLAB Plot Gallery

% Generate points for a cylinder with profile 2 + sin(t)
t = 0:pi/50:2*pi;
[x, y, z] = cylinder(2+sin(t));

% Create a surface plot using the surf function
surf(x, y, z, 'LineStyle', 'none', 'FaceColor', 'interp')

% Turn off the axis and the grid
axis square
axis off
grid off