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

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

X
Type
Any
Required
Yes
Description
Input sample data.
bins
Type
Any
Required
Yes
Description
Bin count scalar or explicit center vector.
normalization
Type
StringScalar
Required
Yes
Default
count
Description
Normalization mode: count, probability, or pdf.
name_value
Type
Any
Required
Variadic
Description
Name/value options and style properties.
name_value
Type
Any
Required
Variadic
Description
Additional name/value options and style properties.
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

N
Type
NumericArray
Description
Histogram bin counts.
centers
Type
NumericArray
Description
Histogram bin centers.
NameTypeDescription
NNumericArrayHistogram bin counts.
centersNumericArrayHistogram bin centers.

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

Errors

RunMat:hist:InvalidArgument
When
Histogram inputs, bins, normalization, weights, or style arguments are invalid.
Message
hist: invalid argument
RunMat:hist:Internal
When
Internal histogram rendering or device conversion fails.
Message
hist: internal operation failed
RunMat:plotting:TooManyOutputs
When
More than 2 output arguments are requested.
Message
hist: too many output arguments
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
RunMat:plotting:TooManyOutputsMore than 2 output arguments are requested.hist: too many output arguments

Behavior

hist(data) uses ten bins by default. Ordinary row and column vectors create one distribution; matrix columns use the existing per-column bin selection.

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.

Rendering and residency

hist supports GPU-aware histogram computation where applicable, but it remains the legacy center-based histogram workflow rather than the object-based histogram API.

Declared source precision and class coverage

single

double

Coordinate broadcasting

none

Runtime contract and boundaries

Catalog default bindings retain the actual RuntimeContext and original rooted BuiltinArguments across parsing, provider readback, delegated calls and completion. Value-selected axes, properties and output counts remain Runtime decisions. Constructor results are host double graphics handles, not numerical GPU arrays; hist instead returns double counts/centres, plotyy up to three distinct handle outputs, and plotmatrix up to five.

Rendering is a fusion boundary and requires the installed graphics host/device. A direct compatible renderer route is not an elementwise or reduction provider kernel. Resident buffers retain their owning provider and existing export/error/completion protocol; an export, readback, allocation, cancellation or emission failure is an error, not permission to replay an attempted operation. Source data and renderer caches have distinct lifetimes. No new distributed chart implementation is declared.

The existing canonical CoordinateWork allocation policy refuses Managed calls before unowned chart scratch, metadata, readback or scene mutation. It checks captured cancellation generation and policy before publication and on completion; ingress failures are Never replay. This is an explicit missing finite owner, not an allocation estimate, algorithm completion or L25 closure. Provider-private allocations, renderer lifetime accounting, synchronous long geometry/copy cooperation, measured throughput and physical presentation remain independent qualification gates.

Native Single/Double/integer source ownership is distinguished from explicit binary64/f32 graphics conversion. The renderer does not promise exact wide-integer pixel positions. Logical, complex, sparse, scalar, vector, matrix, empty and higher-rank forms follow the identity-specific parser rather than a universal implicit cast. Sparse/complex rejection is not an integer not-applicable audit. Full MATLAB properties, browser/native parity and empty-shape conformance are not inferred from migration or historical test references.

Supported representations and remaining forms

The legacy API returns zero, one or two requested outputs: double counts and optionally centres, while retaining the existing plotting behavior. The default is ten bins, not a sample-size formula. A positional vector supplies centres, a scalar supplies a validated count. Integer sample/centre and modern option forms retain their distinct existing compatibility extensions; integer count controls are structural. Modern BinEdges/NumBins/BinWidth/BinLimits/BinMethod/Weights/Normalization controls retain their existing exclusivity and validation rules.

Ordinary 1-by-N and N-by-1 vectors now use one distribution and return row counts/centres. Matrix columns still form separate grouped distributions; automatic/count bins are selected per column, while explicit/shared controls retain the old common-bin owner. No new N-D or empty geometry rule is introduced by that bounded vector correction. Probability and PDF weights use the existing per-column totals and widths.

The eligible resident floating-vector path preserves the existing typed GPU histogram preparation states: complete chart, prepared host bins, or required host statistics. Continuing already successful preparation is not retry permission: after-effect failures remain terminal. Unsupported styling or pre-effect inapplicability retains the existing owner-aware CPU route, not a provider-name heuristic. Finite workspace/renderer completion and CPU long-loop cooperation remain unclosed. Bar getters do not expose count vectors; examples separately assert the real returned numerical counts and retained Runtime fixtures inspect chart data.

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 centres; histogram(data, 'BinEdges', v) treats v as bin edges. histogram returns a chart handle with get/set properties. hist is the legacy plotting/count API: one requested output returns double counts and two return counts and centres; it is not a histogram object alias.

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 · 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 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 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 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
  • Source you can read
  • About RunMat