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

fcontour — Plot contour lines of a scalar function.

fcontour evaluates a function handle over a rectangular two-variable domain and renders contour lines from the sampled values.

Syntax

h = fcontour(f)
h = fcontour(f, xyinterval)
h = fcontour(___, Name, Value, ...)
h = fcontour(ax, ___)

Inputs

NameTypeRequiredDefaultDescription
fAnyYes—Function of two variables, z = f(x,y).
xyintervalNumericArrayNo[-5 5 -5 5]Two- or four-element domain vector.
argsAnyYes—Function-handle and optional domain arguments.
name_valueAnyVariadic—MeshDensity and contour name/value arguments.
axAxesHandleYes—Target axes handle.

Returns

NameTypeDescription
hNumericScalarHandle to the rendered function contour.

Errors

IdentifierWhenMessage
RunMat:fcontour:InvalidArgumentFunction handle, domain, mesh density, axes target, levels, or contour properties are invalid.fcontour: invalid argument
RunMat:fcontour:EvaluationFailedA sampled function handle fails or does not return a scalar numeric value.fcontour: function evaluation failed
RunMat:fcontour:InternalContour construction or rendering fails unexpectedly.fcontour: internal operation failed

How fcontour works

  • fcontour(f) samples f(x,y) on the default [-5 5 -5 5] domain.
  • fcontour(f, [xmin xmax ymin ymax]) uses an explicit rectangular domain; a two-element vector applies the same limits to both axes.
  • fcontour(ax, ___) renders into the requested axes and returns a function-contour graphics handle.
  • Function-handle outputs must be scalar real numeric values at every sampled point; non-finite samples are preserved as contour discontinuities.
  • Typed integer domain vectors, property scalars, and documented level vectors are accepted for all eight integer classes.

Options

  • 'MeshDensity' controls the number of samples along each domain dimension. RunMat accepts exact integer counts from 3 through the resource ceiling of 400.
  • 'LevelList' accepts a nonempty real numeric row or column vector. An integer scalar selects one explicit level, and descending level order is accepted.
  • 'LevelStep' accepts a nonnegative finite real numeric scalar. Zero selects automatic levels and a positive integer crosses one checked contour-geometry conversion boundary.
  • 'LineWidth' accepts a positive finite real numeric scalar and crosses one checked renderer-property conversion boundary.
  • 'Fill' accepts logical values or the exact numeric scalar values zero and one. One adds filled contour bands beneath the contour lines.
  • 'LineColor' accepts the documented text forms. Typed-integer RGB is a separately gated RunMat extension; the undocumented 'Color' alias is not accepted by fcontour.
  • 'DisplayName' sets the function-contour graphics handle display name.

Does RunMat run fcontour on the GPU?

Callback sampling runs on the host.

The resulting contour uses the existing runmat-plot contour rendering path.

GPU memory and residency

fcontour is a callback-sampling builtin. It creates a new sampled contour plot and does not preserve input residency, because the input is a MATLAB function handle rather than a numeric provider buffer.

Examples

Plot function contours over the default domain

fcontour(@(x,y) sin(x) + cos(y));

Set the domain, levels, and mesh density

h = fcontour(@(x,y) x.^2 - y.^2, [-2 2 -1 1], 'LevelList', [-1 0 1], 'MeshDensity', 75);

Using fcontour with coding agents

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

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

FAQ

Does fcontour evaluate the function handle on the GPU?⌄

No. MATLAB function handles can contain arbitrary user code, so RunMat samples them on the host and then hands the sampled grid to the contour renderer.

What happens if the function returns a vector?⌄

RunMat raises RunMat:fcontour:EvaluationFailed; each sampled point must produce one scalar numeric value.

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 · 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 · axes · barh · caxis · cla · clf · clim · colorcube · colororder · copyobj · daspect · datacursormode · dataTipTextRow · 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

Open-source implementation

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

  • View the source for fcontour 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 fcontour works
  • Options
  • Does RunMat run fcontour on the GPU?
  • GPU memory and residency
  • Examples
  • Plot function contours over the default domain
  • Set the domain, levels, and mesh density
  • Using fcontour with coding agents
  • FAQ
  • Related Plotting functions
  • 2D Charts
  • 3D & Surface
  • Images
  • Axes & Layout
  • Appearance
  • Handle Access
  • Other
  • Open-source implementation
  • About RunMat