RunMat
  • Pricing
RunMat
GitHub
GitHub
Sign inTry in browser
DesktopRuntimePhysicsCADAdministrationAgent

Get RunMat updates

New releases, guides and examples.

Product+
  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download
Math+
  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting
Physics+
  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA
Industries+
  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance
Learn+
  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students
Compare+
  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons
Company+
  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms

Product

  • Runtime
  • GPU
  • Parallel
  • Compile
  • Interop and MEX
  • Simulation
  • MCAD
  • ECAD
  • Enterprise
  • AI integrations
  • Pricing
  • Download

Math

  • Signal processing
  • Linear algebra
  • Statistics
  • Curve fitting
  • Differential equations
  • Control systems
  • Optimization
  • Finance
  • Data and tables
  • Plotting

Physics

  • Simulation overview
  • Structural
  • Thermal
  • Electromagnetic
  • Joule heating
  • Thermal stress
  • Acoustics
  • Fluid flow
  • Conjugate heat transfer
  • Fluid–structure
  • What is FEA

Industries

  • Aerospace
  • Automotive and transportation
  • Defense
  • Electronics and semiconductors
  • Energy
  • Industrial machinery
  • Life sciences
  • Quantitative finance

Learn

  • Guides
  • Docs
  • Function reference
  • Language reference
  • Migration guide
  • Changelog
  • MATLAB Online
  • MATLAB AI agent
  • For students

Compare

  • RunMat vs MATLAB
  • RunMat vs Ansys
  • RunMat vs SOLIDWORKS
  • RunMat vs Altium
  • RunMat vs Cadence
  • RunMat vs COMSOL
  • RunMat vs Python
  • RunMat vs Julia
  • RunMat vs Physics AI
  • RunMat vs Octave
  • Benchmarks
  • MATLAB alternatives
  • All comparisons

Company

  • About
  • Blog
  • Contact
  • Source code↗
  • License
  • Privacy
  • Terms
GitHubXLinkedIn

© Dystr, Inc. · RunMat v0.7.1, Nov 17, 2026

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.

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

surf — Plot a surface with optional independent indexed or truecolor CData.

surf creates a surface graphics object from Z or X,Y,Z, optionally with independent color data C. The renderer preserves source geometry and color storage separately.

Syntax

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

Inputs

Z
Type
NumericArray
Required
Yes
Description
Surface height grid.
X
Type
NumericArray
Required
Yes
Description
X axis vector or full coordinate matrix matching Z.
Y
Type
NumericArray
Required
Yes
Description
Y axis vector or full coordinate matrix matching Z.
C
Type
NumericArray
Required
Yes
Description
Independent indexed m-by-n or truecolor m-by-n-by-3 surface color data.
C
Type
NumericArray
Required
Yes
Description
Independent indexed m-by-n or truecolor m-by-n-by-3 color data.
props
Type
Any
Required
Variadic
Description
Name/value surface style options.
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.
CNumericArrayYes—Independent indexed m-by-n or truecolor m-by-n-by-3 surface color data.
CNumericArrayYes—Independent indexed m-by-n or truecolor m-by-n-by-3 color data.
propsAnyVariadic—Name/value surface style options.

Returns

h
Type
NumericScalar
Description
Handle to the rendered surface plot.
NameTypeDescription
hNumericScalarHandle to the rendered surface plot.

Errors

RunMat:surf:InvalidArgument
When
Surface/grid/axis inputs or style name/value arguments are invalid.
Message
surf: invalid argument
RunMat:surf:Internal
When
Internal surface construction or render preparation fails unexpectedly.
Message
surf: internal operation failed
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

Surface geometry and axes

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 authoritative scene data.

Surface handles can be inspected and updated with get/set. view, zlabel, colorbar, colormap, and shading use the same subplot-local axes state. surf fills and shades a surface; mesh emphasizes wireframe geometry, and surfc adds contour overlays.

When vector-axis GPU buffers can be exported through the shared plotting device, surface geometry can remain resident through the floating rendering path. Full host coordinate matrices use the CPU parametric-surface path; other unsupported direct-render combinations gather through the existing source-preparation boundary. Color limits and subplot-local metadata follow the same surface pipeline on either path. The shared surface pipeline also serves image, contour-composite, and surface-style plot families.

Coordinate and color forms

surf(Z) uses column and row indices as X and Y. surf(X,Y,Z) accepts matching coordinate grids or axis vectors. surf(Z,C) and surf(X,Y,Z,C) retain C independently of Z; C is indexed m-by-n data or truecolor m-by-n-by-3 data where [m,n]=size(Z).

Indexed CData uses the axes colormap and color limits in scaled mode. In direct mode, floating values are one-based colormap indices and integer values are zero-based indices. Floating truecolor components lie in [0,1]; NaN makes an affected vertex transparent. Integer truecolor components are normalized from their native class range only at the renderer boundary.

Graphics properties and residency

The returned graphics handle exposes CData and CDataMapping through get/set. Color data is retained with its numeric class and shape for scene replay, while rasterization converts it to renderer colors.

Explicit GPU inputs use the existing plotting-source preparation and may require a documented host gather; this plotting sink does not promise a device-resident graphics handle or an automatic elementwise GPU result. Whole-scene host allocation and browser renderer behavior still require integrated qualification.

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);
h = 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);
h = 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;

h = surf(X, Y, Z);
shading interp;
colormap('turbo');
colorbar;
title('Damped Radial Wavefield');
xlabel('x');
ylabel('y');
zlabel('Amplitude');
view(35, 25);

Color a surface independently of height

Z = [1 2; 3 4]; C = [4 3; 2 1]; h = surf(Z,C); assert(isequal(get(h,'CData'),C));

Rendered surf example

[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 wavefield rendered as a shaded MATLAB surface in RunMat

Compare this result with other chart types in the plot examples.

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.

Can colors differ from surface height?⌄

Yes. Pass C as a separate m-by-n indexed grid or m-by-n-by-3 truecolor grid.

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 · autumn · axes · barh · bone · caxis · cla · clf · clim · colorcube · colororder · cool · copper · copyobj · cylinder · daspect · datacursormode · dataTipTextRow · drawnow · fcontour · figure · fill · fill3 · findobj · fsurf · gobjects · gray · groot · hgload · hgsave · hidden · histogram2 · hold · hot · inferno · isgraphics · ishandle · jet · line · lines · linkaxes · magma · openfig · opengl · pan · parula · patch · pink · plasma · plotmatrix · plotyy · polarhistogram · polarplot · polarscatter · print · quiver3 · ribbon · saveas · savefig · sphere · spring · stackedplot · subtitle · summer · suptitle · text · textscatter · textscatter3 · triplot · turbo · viridis · waitbar · winter · 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

Source you can read

Every RunMat function's source is public. 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 a runtime that executes MATLAB-syntax code fast on any GPU. The runtime is free for individuals, including freelancers; students and faculty at an academic institution, for teaching or research there; contributors to an open-source project, for work on that project; organizations with 250 or fewer people and US$10M or less in annual revenue; and anyone, for non-production use. See runmat.com/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
  • Surface geometry and axes
  • Coordinate and color forms
  • Graphics properties 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
  • Color a surface independently of height
  • Rendered surf example
  • Using surf with coding agents
  • FAQ
  • Related Plotting functions
  • 2D Charts
  • 3D & Surface
  • Images
  • Axes & Layout
  • Appearance
  • Handle Access
  • Other
  • More plotting resources
  • Source you can read
  • About RunMat