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

histogram — Create histogram chart objects in MATLAB and RunMat.

histogram creates object-style histograms using bin-edge semantics. Normalization options, bin controls, and returned handle properties follow MATLAB behavior.

Syntax

h = histogram(X)
h = histogram(X, bins)
h = histogram(X, Name, Value, ...)
h = histogram(X, bins, Name, Value, ...)
h = histogram(ax, X)
h = histogram(ax, X, bins)
h = histogram(ax, X, Name, Value, ...)
h = histogram(ax, X, bins, Name, Value, ...)

Inputs

X
Type
Any
Required
Yes
Description
Input sample data.
bins
Type
Any
Required
Yes
Description
Bin count scalar or explicit edge vector.
name_value
Type
Any
Required
Variadic
Description
Name/value pairs for histogram options and styling.
name_value
Type
Any
Required
Variadic
Description
Additional name/value pairs for options and styling.
ax
Type
NumericScalar
Required
Yes
Description
Target axes handle.
name_value
Type
Any
Required
Variadic
Description
Name/value pairs for options and styling.
NameTypeRequiredDefaultDescription
XAnyYes—Input sample data.
binsAnyYes—Bin count scalar or explicit edge vector.
name_valueAnyVariadic—Name/value pairs for histogram options and styling.
name_valueAnyVariadic—Additional name/value pairs for options and styling.
axNumericScalarYes—Target axes handle.
name_valueAnyVariadic—Name/value pairs for options and styling.

Returns

h
Type
NumericScalar
Description
Handle to the created histogram chart.
NameTypeDescription
hNumericScalarHandle to the created histogram chart.

Errors

RunMat:histogram:InvalidArgument
When
Histogram input arrays, bins, or name/value options are malformed or incompatible.
Message
histogram: invalid argument
RunMat:histogram:Internal
When
Internal render preparation or histogram state registration fails.
Message
histogram: internal operation failed
RunMat:plotting:TooManyOutputs
When
More than one output is requested from a coordinate chart constructor.
Message
plotting: too many output arguments
IdentifierWhenMessage
RunMat:histogram:InvalidArgumentHistogram input arrays, bins, or name/value options are malformed or incompatible.histogram: invalid argument
RunMat:histogram:InternalInternal render preparation or histogram state registration fails.histogram: internal operation failed
RunMat:plotting:TooManyOutputsMore than one output is requested from a coordinate chart constructor.plotting: too many output arguments

Behavior

histogram(data) creates a histogram object handle.

When you pass explicit bins through histogram-style arguments, they are treated as bin edges rather than bin centers.

Normalization modes such as count, probability, percentage, density-style variants, and cumulative forms are part of the evaluation path.

The returned histogram handle exposes properties like bin edges, counts, and normalization through get and accepts updates through set where supported.

This is the preferred histogram API for new code; use hist only when you intentionally want legacy center-based MATLAB semantics.

Rendering and residency

histogram uses histogram evaluation with a handle-based plotting object interface.

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 object API accepts sample data, optional count/edge controls, optional full leading axes and bar styling. Data and exact integer edges retain the existing histcounts evaluation owner; unlike hist, a positional edge vector means edges, not centres. Raw double counts are evaluated once, then normalized for rendering and stored with typed Data, edges, denominator and style metadata on the histogram handle.

BinEdges/NumBins/BinWidth/BinLimits/BinMethod and count/probability/percentage/density/PDF/cumulative normalization retain the actual underlying validation and supported get/set surface. Shape admission, nonfinite handling and integer membership comparisons belong to histcounts. The full figure+axes identity is selected before publication rather than reusing a foreign axes index in the active figure. Resident Data is eagerly retained by owning-provider readback before evaluation; this is not a direct no-readback histogram-object kernel.

Examples

Create a histogram object from data

data = randn(1, 1000);
h = histogram(data);

Expected output:

% h is a histogram object handle

Use explicit bin edges and inspect the handle

data = randn(1, 500);
edges = -3:0.25:3;
h = histogram(data, 'BinEdges', edges);
get(h, 'BinEdges');

Apply normalization through histogram semantics

data = randn(1, 500);
h = histogram(data, 'Normalization', 'probability');
get(h, 'Normalization')

Expected output:

ans =
    'probability'

Overlaid distributions

a = 2 + 1.2*randn(1, 5000);
b = 4 + 0.8*randn(1, 5000);

h1 = histogram(a, 'BinEdges', -2:0.25:8, 'Normalization', 'probability');
set(h1, 'DisplayName', 'Process A');
hold on;
h2 = histogram(b, 'BinEdges', -2:0.25:8, 'Normalization', 'probability');
set(h2, 'DisplayName', 'Process B');
hold off;

title('Distribution Comparison');
xlabel('Measurement');
ylabel('Probability');
legend;
grid on;

Rendered histogram example

rng(7);
a = 2 + 1.2*randn(1, 5000);
b = 4 + 0.8*randn(1, 5000);

h1 = histogram(a, 'BinEdges', -2:0.25:8, 'Normalization', 'probability');
set(h1, 'DisplayName', 'Process A');
hold on;
h2 = histogram(b, 'BinEdges', -2:0.25:8, 'Normalization', 'probability');
set(h2, 'DisplayName', 'Process B');
hold off;

title('Distribution Comparison');
xlabel('Measurement');
ylabel('Probability');
legend();
grid on;
Expected output:
Two process distributions rendered as overlaid probability histograms in RunMat

Compare this result with other chart types in the plot examples.

Using histogram with coding agents

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

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

FAQ

How do I set a specific number of bins?⌄

Pass the bin count as a second positional argument or use the 'NumBins' name-value pair.

data = randn(1, 1000);
histogram(data, 30);                    % 30 bins
histogram(data, 'NumBins', 50);         % 50 bins
histogram(data, 'BinEdges', -3:0.1:3); % exact edges

Explicit BinEdges gives you full control over where each bin starts and ends.

How do I overlay two distributions on the same axes?⌄

Use hold on between histogram calls and set 'Normalization' to 'probability' so both distributions are on a comparable scale.

histogram(randn(1,1000), 'Normalization', 'probability');
hold on;
histogram(randn(1,1000) + 2, 'Normalization', 'probability');
legend('dist A', 'dist B');
What's the difference between histogram and hist?⌄

histogram is the modern API: it uses bin-edge semantics, returns a handle object you can inspect with get/set, and supports normalization modes like 'probability' and 'pdf'. hist is the legacy API that interprets a second vector argument as bin centers. Use histogram for new code unless you specifically need center-based binning from a legacy workflow.

Related Plotting functions

2D Charts

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

  • View the source for histogram 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 histogram object from data
  • Use explicit bin edges and inspect the handle
  • Apply normalization through histogram semantics
  • Overlaid distributions
  • Rendered histogram example
  • Using histogram 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