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

clf — Clear figure contents in MATLAB and RunMat plotting.

clf clears the contents of the current figure while leaving the figure handle itself alive. It accepts explicit figure numbers, figure-number arrays, and RunMat's 'all' selector. Typed integer figure numbers are an exact structural convenience available in RunMat mode; compatibility mode accepts ordinary double figure numbers.

Syntax

result = clf()
result = clf(targets...)

Inputs

targets
Type
Any
Required
Variadic
Description
Figure handle(s) or mode tokens ('all', 'reset').
NameTypeRequiredDefaultDescription
targetsAnyVariadic—Figure handle(s) or mode tokens ('all', 'reset').

Returns

result
Type
NumericScalar
Description
Cleared handle for single-target calls or count for multi/all clears.
NameTypeDescription
resultNumericScalarCleared handle for single-target calls or count for multi/all clears.

Errors

RunMat:clf:InvalidArgument
When
One or more clear targets are invalid.
Message
clf: invalid argument
RunMat:clf:Internal
When
Internal figure clear operation fails.
Message
clf: internal operation failed
RunMat:clf:TooManyOutputs
When
More than 1 output arguments are requested.
Message
clf: too many output arguments
IdentifierWhenMessage
RunMat:clf:InvalidArgumentOne or more clear targets are invalid.clf: invalid argument
RunMat:clf:InternalInternal figure clear operation fails.clf: internal operation failed
RunMat:clf:TooManyOutputsMore than 1 output arguments are requested.clf: too many output arguments

Behavior

clf() clears the current figure.

clf(handle) clears the specified figure handle.

clf('all') is a separately gated RunMat convenience that clears every known figure and returns the number of figures that were cleared; compatibility mode rejects it before plotting-state access.

clf(handle1, handle2, ...) is a separately gated RunMat convenience that clears multiple figures and returns the number cleared. Compatibility syntax uses one figure object or figure array.

clf('reset') is currently treated the same as plain clf.

In RunMat mode, scalar and array figure numbers can use any of the eight integer classes. Values are read from authoritative integer storage and must be positive and no larger than uint32's maximum.

Typed integer figure numbers are rejected in compatibility mode because the public compatibility contract documents figure numbers but does not advertise integer classes. GPU-resident numeric targets are rejected without provider dispatch.

Placement and residency

clf clears plotting state only. It does not execute numeric GPU kernels.

clf only mutates host plotting state. Figure-number controls must be host values; resident numeric targets are rejected without gathering.

clf performs no provider dispatch; it clears figures from the plotting registry and renderer state.

Execution, authority, and current limits

The canonical binding uses the same runtime implementation in interpreter and compiled execution. Requested output arity is checked before this operation can mutate graphics state or gather coordinate data; discarding an output does not suppress the operation.

Graphics handles encode local registry identities, not transferable figure, axes, or chart state. Copying a numeric handle to a worker, foreign runtime, or serialized value does not transfer its graphics authority. This host operation is a fusion boundary; no numeric GPU kernel or distributed implementation is supplied.

Finite Managed allocation remains an L25 obligation: complete scratch, metadata, retained graphics-state, and output ownership are not yet quoted by these implementations. The shared graphics admission owner refuses Managed policy before unowned work, captures cancellation authority, and checks it before publication; that safety fence is not finite-allocation completion. Unbounded host scratch may still contain synchronous loops.

Plain clf and clf reset currently share the same full FigureState replacement. Figure properties are reset along with contents; the distinct MATLAB plain-versus-reset lifecycle is still an explicit compatibility obligation. The figure identifier remains alive. Clearing several figures is not a transactional rollback operation if an external authority changes between individual clears.

Examples

Clear the current figure after plotting

figure(1);
plot(1:5, [1 4 2 5 3]);
out = clf()

Clear a specific figure by handle

figure(3);
plot(1:5, 1:5);
out = clf(3)

Clear every figure

close('all');
figure(1); plot(1:5, 1:5);
figure(2); plot(1:5, [5 4 3 2 1]);
count = clf("all")

Using clf with coding agents

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

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

FAQ

Does clf delete the figure handle itself?⌄

No. It clears the figure contents but keeps the figure handle selected and available.

What does clf('reset') do today?⌄

RunMat parses the keyword for compatibility, but the current implementation treats it the same as plain clf.

What does clf('all') return?⌄

It returns the number of figures that were cleared. When no figures exist, it returns 0.

Can figure numbers use integer classes?⌄

Yes in RunMat mode. int8, int16, int32, int64, uint8, uint16, uint32, and uint64 are exact structural selectors, subject to the positive uint32 figure-number range. Compatibility mode requires an ordinary double figure number.

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 · autumn · axes · barh · bone · caxis · cla · 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

Source you can read

Every RunMat function's source is public. Read exactly how clf is executed, line by line, in Rust.

  • View the source for clf 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
  • Placement and residency
  • Execution, authority, and current limits
  • Examples
  • Clear the current figure after plotting
  • Clear a specific figure by handle
  • Clear every figure
  • Using clf with coding agents
  • FAQ
  • Related Plotting functions
  • 2D Charts
  • 3D & Surface
  • Images
  • Axes & Layout
  • Appearance
  • Handle Access
  • Other
  • Source you can read
  • About RunMat