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

hist — Create legacy center-based histograms in MATLAB and RunMat.

hist creates legacy histograms using bin-center semantics. When the second argument is a vector, it is interpreted as bin centers rather than bin edges, consistent with MATLAB behavior.

Syntax

N = hist(X)
N = hist(X, bins)
N = hist(X, normalization)
N = hist(X, Name, Value, ...)
N = hist(X, bins, Name, Value, ...)
[counts, centers] = hist(X)
[counts, centers] = hist(X, bins)

Inputs

NameTypeRequiredDefaultDescription
XAnyYes—Input sample data.
binsAnyYes—Bin count scalar or explicit center vector.
normalizationStringScalarYescountNormalization mode: count, probability, or pdf.
name_valueAnyVariadic—Name/value options and style properties.
name_valueAnyVariadic—Additional name/value options and style properties.

Returns

NameTypeDescription
NNumericArrayHistogram bin counts.
centersNumericArrayHistogram bin centers.

Returned values from hist depend on how many outputs the caller requests.

Errors

IdentifierWhenMessage
RunMat:hist:InvalidArgumentHistogram inputs, bins, normalization, weights, or style arguments are invalid.hist: invalid argument
RunMat:hist:InternalInternal histogram rendering or device conversion fails.hist: internal operation failed

How hist works

  • hist(data) uses a default number of bins based on the input size, following MATLAB-style legacy behavior.
  • hist(data, v) interprets v as bin centers, not bin edges. This is the key semantic difference from histogram.
  • hist is a plotting-style histogram command, while histogram returns a first-class histogram object handle.
  • Normalization and bin-control workflows are supported, but the builtin should still be documented and used as the legacy center-based histogram path rather than as an alias of histogram.
  • GPU-aware computation is used where supported, but semantics stay aligned with legacy MATLAB hist behavior.

Examples

Create a default legacy histogram

data = randn(1, 1000);
hist(data);

Pass explicit bin centers

data = randn(1, 500);
centers = -3:0.5:3;
hist(data, centers);

Expected output:

% Here the second argument is interpreted as bin centers, not edges

Compare legacy hist semantics with modern histogram intent

data = randn(1, 300);
hist(data, -2:0.5:2);

Expected output:

% Use histogram(...) instead when you want bin-edge semantics and an object handle

Using hist with coding agents

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

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

FAQ

What's the actual difference between hist and histogram?⌄

The critical difference is how the second argument is interpreted. hist(data, v) treats v as bin centers. histogram(data, 'BinEdges', v) treats v as bin edges. Beyond that, histogram returns a handle object with properties you can query via get, while hist is a fire-and-forget plotting command.

When should I use hist instead of histogram?⌄

Use hist when you're porting legacy MATLAB code that relies on center-based binning or when you want a quick distribution plot without needing a handle object. For anything new—especially if you need normalization modes, bin-edge control, or programmatic access to bin counts—use histogram instead.

Related Plotting functions

2D Charts

area · bar · errorbar · heatmap · 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 · 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 hist is executed, line by line, in Rust.

  • View the source for hist 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 hist works
  • Examples
  • Create a default legacy histogram
  • Pass explicit bin centers
  • Compare legacy hist semantics with modern histogram intent
  • Using hist 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