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

stairs — Create staircase line plots for sampled or piecewise-constant data with MATLAB-compatible stairs syntax.

stairs creates a piecewise-constant line from Y alone or paired X,Y coordinates and returns a graphics handle. X and Y may use single, double, or any of the eight integer classes. RunMat keeps the native source class and exact values for XData, YData, and saved figure scenes; the plotting renderer receives a derived floating representation, so rendering does not replace or round the authoritative source data.

Syntax

h = stairs(Y)
h = stairs(X, Y)
h = stairs(X, Y, LineSpec)
h = stairs(X, Y, Name, Value, ...)
h = stairs(ax, Y)
h = stairs(ax, X, Y)
h = stairs(ax, X, Y, LineSpec)
h = stairs(ax, X, Y, Name, Value, ...)

Inputs

NameTypeRequiredDefaultDescription
YNumericArrayYes—Y samples. X defaults to 1:numel(Y).
XNumericArrayYes—X samples.
YNumericArrayYes—Y samples.
lineSpecStyleSpecYes—Line style shorthand such as '--r'.
propsAnyVariadic—Name/value style properties.
axAxesHandleYes—Target axes handle.

Returns

NameTypeDescription
hNumericScalarHandle to the rendered stairs plot.

Errors

IdentifierWhenMessage
RunMat:stairs:InvalidArgumentInput data, axes targeting, or style arguments are invalid.stairs: invalid argument
RunMat:stairs:InternalInternal plot construction or rendering fails unexpectedly.stairs: internal operation failed

How stairs works

  • stairs(y) uses implicit x-values 1:n, while stairs(x, y) uses explicit paired coordinates.
  • The returned value is a plot handle that works with get and set.
  • Marker styling and display names can be updated through the same handle/property system used by line plots.
  • XData and YData retain the input numeric class, shape, and exact host values, including int64 and uint64 values above flintmax.
  • Figure-scene serialization preserves typed source data. Loading an older scene without typed source fields reconstructs ordinary double source data for backward compatibility.
  • Step-plot rendering is subplot-local and respects current axes state just like plot and scatter.
  • GPU-backed geometry is preferred when exported buffers and the shared plotting device are available.

Examples

Plot a sampled staircase signal

t = 0:5;
stairs(t, cumsum([1 -1 2 -2 1 0]));

Use MATLAB-style y-only shorthand

stairs([3 1 4 1 5 9]);

Style a stairs object and label it for the legend

h = stairs(0:4, [1 2 2 3 5]);
set(h, 'Color', 'm', 'LineWidth', 2, 'DisplayName', 'sampled signal');
legend;

Piecewise-constant step response

t = 0:0.5:10;
y = 1 - exp(-0.5*t);

h = stairs(t, y);
set(h, 'LineWidth', 2);
title('First-Order Step Response');
xlabel('Time (s)');
ylabel('Output');
grid on;
Expected output:
Piecewise-constant step response

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

Using stairs with coding agents

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

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

FAQ

When should I use stairs instead of plot?⌄

stairs draws piecewise-constant steps between points, while plot linearly interpolates. Use stairs when your data is held constant between samples—DAC output, quantized signals, sample-and-hold systems, or any situation where the value doesn't change smoothly between observations.

How do I visualize a digital signal with stairs?⌄

Pass your time vector and signal values directly. The staircase rendering naturally represents digital/discrete-time signals where values snap between levels.

t = 0:0.01:1;
signal = double(square(2*pi*5*t) > 0);
stairs(t, signal);
ylim([-0.2 1.2]);

This avoids the misleading diagonal transitions that plot would draw between high and low states.

Can I add markers to a stairs plot?⌄

Yes. Set the 'Marker' property on the returned handle, just like you would with plot.

h = stairs(0:4, [1 3 2 4 1]);
set(h, 'Marker', 'o', 'MarkerSize', 6);

Markers appear at each data point (the step corners), not along the flat segments.

Related Plotting functions

2D Charts

area · bar · errorbar · heatmap · hist · histogram · loglog · pie · plot · scatter · semilogx · semilogy · 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 · 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 stairs is executed, line by line, in Rust.

  • View the source for stairs 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 stairs works
  • Examples
  • Plot a sampled staircase signal
  • Use MATLAB-style y-only shorthand
  • Style a stairs object and label it for the legend
  • Piecewise-constant step response
  • Using stairs 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