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

mesh — Create wireframe surface plots in MATLAB and RunMat.

mesh creates wireframe surface plots from vector axes or meshgrid-style coordinates plus height data. Handle behavior and axis integration follow MATLAB semantics.

Syntax

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

Inputs

Z
Type
NumericArray
Required
Yes
Description
Surface height grid.
X
Type
NumericArray
Required
Yes
Description
X axis vector/meshgrid matrix matching Z columns.
Y
Type
NumericArray
Required
Yes
Description
Y axis vector/meshgrid matrix matching Z rows.
props
Type
Any
Required
Variadic
Description
Name/value surface style options.
NameTypeRequiredDefaultDescription
ZNumericArrayYes—Surface height grid.
XNumericArrayYes—X axis vector/meshgrid matrix matching Z columns.
YNumericArrayYes—Y axis vector/meshgrid matrix matching Z rows.
propsAnyVariadic—Name/value surface style options.

Returns

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

Errors

RunMat:mesh:InvalidArgument
When
Surface input arrays or style name/value arguments are invalid.
Message
mesh: invalid argument
RunMat:mesh:Internal
When
Internal surface generation/render preparation fails unexpectedly.
Message
mesh: internal operation failed
RunMat:plotting:TooManyOutputs
When
More than one output is requested from a coordinate chart constructor.
Message
plotting: too many output arguments
IdentifierWhenMessage
RunMat:mesh:InvalidArgumentSurface input arrays or style name/value arguments are invalid.mesh: invalid argument
RunMat:mesh:InternalInternal surface generation/render preparation fails unexpectedly.mesh: internal operation failed
RunMat:plotting:TooManyOutputsMore than one output is requested from a coordinate chart constructor.plotting: too many output arguments

Behavior

mesh(Z) uses implicit axes, while mesh(X, Y, Z) accepts vector axes or meshgrid-style coordinate matrices.

XData, YData, and ZData retain native single, double, or integer class and exact host values even when renderer geometry is materialized into a floating domain.

The documented independent color-array and leading-axes forms are not implemented yet; this is a general graphics-surface gap rather than an integer coercion rule.

The builtin returns a surface handle, so mesh plots can still be inspected through the graphics-object system.

mesh is the wireframe-oriented companion to surf; for combined wireframe plus contour overlays, use meshc.

RunMat uses the shared surface pipeline for mesh rendering, so view, z-axis labeling, and subplot-local state behave consistently across the surface family.

GPU-backed rendering is preferred when the plotting device can consume exported buffers directly; automatic resident inputs also take one exact owner-aware host snapshot for property queries and figure persistence.

Rendering and residency

mesh retains native host coordinate storage for graphics properties and scene persistence, including an owner-aware exact snapshot of resident inputs, while rendering remains an explicit floating/device boundary.

Declared source precision and class coverage

single

double

Coordinate broadcasting

none

Runtime contract and boundaries

Graphics results are host double handles; fill/fill3 may return a row of handles for independently created polygon columns/groups. Sphere instead supports zero through three requested outputs: statement form plots, while output forms return host double coordinate grids. Handle aliases, value-selected options and exact graphics receiver roles are resolved by Runtime, not guessed from scalar facts.

The existing numerical and geometry owners validate coordinates, integer controls, shapes and properties. Single/double and all eight integer source classes retain their native storage wherever the object has authoritative source properties; client geometry and renderer buffers are deliberate floating boundaries, not a promise of exact wide-integer pixel positions. There is no sparse/complex plotting implementation or numeric broadcasting promise here. Logical, scalar, vector, matrix, rank and empty admission follows each documented owner below rather than a universal coercion.

RuntimeOwned preparation retains the original BuiltinArguments through suspension and completion. Eligible direct GPU routes require the live owning provider, admitted precision/storage/shape, compatible exports and installed plotting device. NoAttempt means pre-effect inapplicability, not permission to swallow export, allocation, cancellation or emission errors. Existing provider errors are propagated and ingress errors are terminal Never replay. Source-property queries and figure persistence may require explicit owner-aware readback; surface property snapshots and quiver3/patch construction are not zero-copy routes.

Canonical UserInterface capability and host-callback effects reflect scene creation/presentation; function-sampling entries additionally declare Unknown effects for arbitrary user callbacks and require the Process execution stack. NativeAndWasm means the Runtime entry is portable, not that an absent graphics host is emulated. Portable Runtime linkage introduces no separate native numerical library artifact. Rendering is a fusion boundary and distributed execution is unsupported; no numeric provider kernel or fusion primitive is invented.

Chart scratch, metadata, retained render state and the sphere coordinate builder do not yet have complete finite host allocation ownership. The shared canonical HostAllocationReceipt policy guard refuses Managed work before extraction/gather/callbacks or scene mutation, preserves ordinary Unbounded routes, and checks captured cancellation generation and policy before publication. This is an explicit L25 gap, not allocation completion. Long synchronous geometry/copy loops, renderer/provider-private allocation accounting, full MATLAB property parity, physical performance and actual example execution remain independently required.

Supported representations and remaining forms

Supported input forms are Z and X,Y,Z, followed by the existing shared surface style name/value grammar. Z-only styles retain the rooted tail instead of being misclassified as three coordinates. X indexes columns and Y indexes rows. Explicit vectors or opposite-varying meshgrid coordinate matrices must match the height grid; mesh/meshc/surfc do not implement arbitrary parametric X/Y matrices, independent C color arrays or leading-axes forms merely because surf supports a broader surface representation.

Native Single/double/integer XData/YData/ZData and their shape remain authoritative for properties and scene persistence. Resident source snapshots are real owning-provider gathers even when eligible floating rendering also uses device buffers. A retained native property snapshot and a later host geometry fallback can perform repeated owning-provider readback/copy of the same resident source. This is an explicit performance frontier, not a precision-preserving provider numerical result or a one-readback guarantee. Complex/sparse inputs and malformed/empty grids follow existing shape/type errors, not silently accepted MATLAB parity.

Surface style parsing includes ColorMap/Colormap, Alpha/FaceAlpha, Wireframe, Shading, FaceColor, EdgeColor, Lighting, Visible and DisplayName according to the shared style owner. Mesh defaults to Turbo/faceted/wireframe; surfc defaults to Parula/smooth and composites add default-level contours at the surface base. The result is the primary surface handle, not a vector of composite handles. Broader property compatibility remains incomplete.

Examples

Create a wireframe mesh from a height field

[X, Y] = meshgrid(linspace(-2, 2, 60), linspace(-2, 2, 60));
Z = sin(X.^2 + Y.^2);
mesh(X, Y, Z);

Compare wireframe presentation with subplot-local state

subplot(1, 2, 1);
[X, Y] = meshgrid(linspace(-2, 2, 40), linspace(-2, 2, 40));
Z = cos(X) .* sin(Y);
mesh(X, Y, Z);
view(3);
subplot(1, 2, 2);
surf(X, Y, Z);
view(3);

Inspect the returned surface handle from mesh

[X, Y] = meshgrid(1:20, 1:20);
Z = X + Y;
h = mesh(X, Y, Z);
get(h, 'Type')

Expected output:

ans =
    'surface'

Saddle surface showing grid structure

[X, Y] = meshgrid(linspace(-3, 3, 60), linspace(-3, 3, 60));
Z = X.^2 - Y.^2;

mesh(X, Y, Z);
colormap('jet');
colorbar;
title('Hyperbolic Paraboloid');
xlabel('x');
ylabel('y');
zlabel('z = x^2 - y^2');
view(40, 30);

Rendered mesh example

[X, Y] = meshgrid(linspace(-3, 3, 60), linspace(-3, 3, 60));
Z = X.^2 - Y.^2;

mesh(X, Y, Z);
colormap('jet');
colorbar;
title('Hyperbolic Paraboloid');
xlabel('x');
ylabel('y');
zlabel('z = x^2 - y^2');
view(40, 30);
Expected output:
Hyperbolic paraboloid rendered as a MATLAB wireframe mesh in RunMat

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

Using mesh with coding agents

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

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

FAQ

Can I get a filled surface instead of wireframe?⌄

That's what surf is for. mesh draws only the grid lines with transparent faces, while surf fills the faces with colormap-derived colors. If you want the wireframe look but with partial fill, there's no built-in blend — use surf with a low alpha or switch to mesh and accept the wireframe.

How do I combine a mesh with contour lines underneath?⌄

Use meshc instead of mesh. It draws the same wireframe surface but projects contour lines onto the base plane automatically.

[X, Y] = meshgrid(linspace(-2, 2, 50));
Z = sin(X.^2 + Y.^2);
meshc(X, Y, Z);
Can I control transparency on a mesh plot?⌄

By default mesh draws open wireframe faces rather than a filled surface. For a semi-transparent filled surface, use surf and its FaceAlpha property. RunMat mesh also shares the surface-style parser: Alpha/FaceAlpha is accepted and retained, and SurfacePlot carries that alpha into its vertex/material data rather than unconditionally forcing every wireframe edge opaque. Actual presentation and blending follow the installed graphics renderer.

Related Plotting functions

2D Charts

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

3D & Surface

contour · contour3 · contourf · meshc · plot3 · quiver · scatter3 · surf · 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 mesh is executed, line by line, in Rust.

  • View the source for mesh 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
  • Behavior
  • Rendering and residency
  • Declared source precision and class coverage
  • Coordinate broadcasting
  • Runtime contract and boundaries
  • Supported representations and remaining forms
  • Examples
  • Create a wireframe mesh from a height field
  • Compare wireframe presentation with subplot-local state
  • Inspect the returned surface handle from mesh
  • Saddle surface showing grid structure
  • Rendered mesh example
  • Using mesh 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