RunMat
  • Pricing
RunMat
GitHub
GitHub
DownloadSign InTry in Browser
DesktopRuntimeServer
RunMat

Run math blazing fast

GitHubX (Twitter)LinkedIn

Company

  • About
  • Pricing
  • Contact

Explore

  • RunMat for academia
  • RunMat vs MATLAB Online
  • Benchmarks

Get product updates and release notes from the RunMat team.

© 2026 Dystr · Made withfor the scientific community.

RunMat™ is a registered trademark of Dystr, Inc. MATLAB® is a registered trademark of The MathWorks, Inc. RunMat is not affiliated with, endorsed by, or sponsored by The MathWorks, Inc.

LicensePrivacy
/
See all docs
Builtin Reference
    • addpoints
    • ancestor
    • animatedline
    • area
    • axes
    • axis
    • bar
    • barh
    • box
    • caxis
    • cla
    • clf
    • clim
    • colorbar
    • colorcube
    • colormap
    • colororder
    • contour
    • contour3
    • contourf
    • copyobj
    • daspect
    • datacursormode
    • dataTipTextRow
    • errorbar
    • fcontour
    • figure
    • fill
    • fill3
    • findobj
    • fsurf
    • gca
    • gcf
    • get
    • gobjects
    • grid
    • groot
    • heatmap
    • hgload
    • hgsave
    • hidden
    • hist
    • histogram
    • histogram2
    • hold
    • image
    • imagesc
    • imshow
    • legend
    • line
    • linkaxes
    • loglog
    • mesh
    • meshc
    • openfig
    • opengl
    • pan
    • parula
    • patch
    • pie
    • plot
    • plot3
    • plotmatrix
    • plotyy
    • polarhistogram
    • polarplot
    • polarscatter
    • print
    • quiver
    • quiver3
    • ribbon
    • saveas
    • savefig
    • scatter
    • scatter3
    • semilogx
    • semilogy
    • set
    • sgtitle
    • shading
    • sphere
    • stackedplot
    • stairs
    • stem
    • subplot
    • subtitle
    • suptitle
    • surf
    • surfc
    • text
    • textscatter
    • textscatter3
    • title
    • triplot
    • view
    • waitbar
    • wordcloud
    • xlabel
    • xlim
    • xline
    • xscale
    • xtickangle
    • xtickformat
    • xticklabels
    • xticks
    • ylabel
    • ylim
    • yline
    • yscale
    • ytickangle
    • ytickformat
    • yticklabels
    • yticks
    • zlabel
    • zlim
    • zoom

surf — Create 3-D surface plots from height grids or mesh coordinates with MATLAB-compatible surf syntax.

surf creates shaded 3-D surfaces from vector axes plus height data, meshgrid coordinates, or full parametric coordinate matrices. It returns a surface handle and follows MATLAB-compatible argument and property behavior.

Syntax

h = surf(Z)
h = surf(X, Y, Z)
h = surf(Z, Name, Value, ...)
h = surf(X, Y, Z, Name, Value, ...)

Inputs

NameTypeRequiredDefaultDescription
ZNumericArrayYes—Surface height grid.
XNumericArrayYes—X axis vector or full coordinate matrix matching Z.
YNumericArrayYes—Y axis vector or full coordinate matrix matching Z.
propsAnyVariadic—Name/value surface style options.

Returns

NameTypeDescription
hNumericScalarHandle to the rendered surface plot.

Errors

IdentifierWhenMessage
RunMat:surf:InvalidArgumentSurface/grid/axis inputs or style name/value arguments are invalid.surf: invalid argument
RunMat:surf:InternalInternal surface construction or render preparation fails unexpectedly.surf: internal operation failed

How surf works

  • surf(Z) uses implicit axes, while surf(X, Y, Z) accepts vector axes, meshgrid-style coordinate matrices, or full parametric coordinate matrices, following MATLAB surf call forms.
  • XData, YData, and ZData retain native single, double, or integer class, exact values, and shape. Vertex generation, color preparation, and rendering are explicit floating boundaries and do not replace that authoritative scene data.
  • The returned value is a surface handle that can be inspected and updated through get and set.
  • Surface plots naturally interact with view, zlabel, colorbar, colormap, and shading because they all operate on the same subplot-local axes state.
  • GPU-backed surface rendering is the preferred path when exported vector-axis buffers and the shared plotting device are available; full host coordinate matrices render through the same CPU surface path used for parametric surfaces.
  • surf is the shaded/fill-oriented member of the surface family, while mesh emphasizes wireframe rendering and surfc adds contour overlays.

Does RunMat run surf on the GPU?

The surface pipeline is shared across multiple plot families, which keeps surf aligned with image, contour-composite, and surface-style rendering behavior.

Vector-axis GPU inputs can remain on device when the renderer shares the provider context; full coordinate matrices use the host parametric-surface path after any required gather.

Surface color limits and subplot-local metadata stay consistent regardless of whether the geometry is emitted from GPU buffers or host tensors.

GPU memory and residency

surf preserves GPU residency on the vector-axis happy path through the shared surface rendering pipeline. When a direct GPU render path is not available for the active input combination, including full coordinate matrices, RunMat gathers once and builds the same surface plot semantics on the fallback path.

Examples

Create a shaded surface from a height grid

[X, Y] = meshgrid(linspace(-2, 2, 80), linspace(-2, 2, 80));
Z = sin(X.^2 + Y.^2) ./ (1 + X.^2 + Y.^2);
surf(X, Y, Z);

Pair surf with colormap, shading, and colorbar

[X, Y] = meshgrid(linspace(-3, 3, 100), linspace(-3, 3, 100));
Z = cos(X) .* sin(Y);
surf(X, Y, Z);
colormap('jet');
shading interp;
colorbar;

Adjust camera state and z-axis labeling for a surface

[X, Y] = meshgrid(linspace(-2, 2, 60), linspace(-2, 2, 60));
Z = X .* exp(-X.^2 - Y.^2);
h = surf(X, Y, Z);
zlabel('Height');
view(45, 30);
get(h, 'Type')

Expected output:

ans =
    'surface'

Damped radial ripple with interpolated shading

[X, Y] = meshgrid(linspace(-4, 4, 200), linspace(-4, 4, 200));
R = sqrt(X.^2 + Y.^2) + 0.01;
Z = sin(3*R) ./ R;

surf(X, Y, Z);
shading interp;
colormap('turbo');
colorbar;
title('Damped Radial Wavefield');
xlabel('x');
ylabel('y');
zlabel('Amplitude');
view(35, 25);
Expected output:
Damped radial ripple with interpolated shading

Compare this result with other chart types in the MATLAB Plot Gallery.

Using surf with coding agents

Open a RunMat example with live inputs, then ask the agent to explain how surf changes the result.

Run a small surf example, explain the result, then change one input and compare the output.

FAQ

How do I change the colormap on a surf plot?⌄

Call colormap after surf to swap the palette. The colormap applies to the current axes, so it works per-subplot.

surf(X, Y, Z);
colormap('turbo');

Any named colormap ('parula', 'jet', 'hot', etc.) or an Nx3 matrix of RGB values works here.

How do I rotate or set the 3-D viewing angle?⌄

Use view(az, el) where az is the azimuth in degrees and el is the elevation. For example, view(45, 30) gives you a 45-degree orbit at 30 degrees above the xy-plane. view(3) is a shortcut for the default 3-D perspective, and view(2) snaps to a top-down 2-D projection.

What's the difference between surf and mesh?⌄

surf renders a shaded, filled surface where face colors come from the colormap. mesh draws only the wireframe grid lines with no face fill. Use surf when you want to visualize the shape as a solid surface, and mesh when you want to see through the geometry to understand the grid structure underneath.

Related Plotting functions

2D Charts

area · bar · errorbar · heatmap · hist · histogram · loglog · pie · plot · scatter · semilogx · semilogy · stairs · stem

3D & Surface

contour · contour3 · contourf · mesh · meshc · plot3 · quiver · scatter3 · surfc

Images

image · imagesc · imshow

Axes & Layout

axis · box · grid · sgtitle · subplot · title · view · zlabel

Appearance

colorbar · colormap · legend · shading

Handle Access

gca · gcf · get · set

Other

addpoints · ancestor · animatedline · axes · barh · caxis · cla · clf · clim · colorcube · colororder · copyobj · daspect · datacursormode · dataTipTextRow · fcontour · figure · fill · fill3 · findobj · fsurf · gobjects · groot · hgload · hgsave · hidden · histogram2 · hold · line · linkaxes · openfig · opengl · pan · parula · patch · plotmatrix · plotyy · polarhistogram · polarplot · polarscatter · print · quiver3 · ribbon · saveas · savefig · sphere · stackedplot · subtitle · suptitle · text · textscatter · textscatter3 · triplot · waitbar · wordcloud · xlabel · xlim · xline · xscale · xtickangle · xtickformat · xticklabels · xticks · ylabel · ylim · yline · yscale · ytickangle · ytickformat · yticklabels · yticks · zlim · zoom

More plotting resources

  • Choosing the right plot type
  • Styling plots and axes
  • Plot replay and export
  • Complete plotting guide

Open-source implementation

Unlike proprietary runtimes, every RunMat function is open-source. Read exactly how surf is executed, line by line, in Rust.

  • View the source for surf in Rust on GitHub
  • Learn how the RunMat runtime works
  • Found a bug? Open an issue with a minimal reproduction.

About RunMat

RunMat is an open-source runtime that executes MATLAB-syntax code blazing on any GPU. It is licensed under the Apache 2.0 license.

  • RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed. Simulations that took hours now take minutes.
  • Start running code in seconds. RunMat runs in the browser, on the desktop, or from the CLI. No license server, no IT ticket.

Getting started · Benchmarks · Pricing

Download RunMat

Download RunMat for full performance, or use RunMat in your browser for zero setup.

Download RunMatOpen Sandbox
On this page
  • Syntax
  • Inputs
  • Returns
  • Errors
  • How surf works
  • Does RunMat run surf on the GPU?
  • GPU memory and residency
  • Examples
  • Create a shaded surface from a height grid
  • Pair surf with colormap, shading, and colorbar
  • Adjust camera state and z-axis labeling for a surface
  • Damped radial ripple with interpolated shading
  • Using surf with coding agents
  • FAQ
  • Related Plotting functions
  • 2D Charts
  • 3D & Surface
  • Images
  • Axes & Layout
  • Appearance
  • Handle Access
  • Other
  • More plotting resources
  • Open-source implementation
  • About RunMat