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
    • all
    • any
    • bounds
    • cummax
    • cummin
    • cumprod
    • cumsum
    • cumtrapz
    • diff
    • gradient
    • max
    • maxk
    • mean
    • median
    • min
    • mink
    • movmax
    • movmean
    • movmedian
    • movmin
    • movprod
    • movstd
    • movsum
    • movvar
    • nnz
    • prod
    • rms
    • std
    • sum
    • trapz
    • var

min — Find minimum values by reduction or pairwise comparison.

min(A) reduces along the first non-singleton dimension and can also return indices. min(A,B) compares operands elementwise and has one output; an empty second argument selects the reduction grammar.

Syntax

M = min(A)
[M, I] = min(A)
M = min(A, B)
M = min(A, [], dim)
[M, I] = min(A, [], dim)
M = min(A, [], vecdim)
All supported min forms
M = min(A)
[M, I] = min(A)
M = min(A, B)
M = min(A, [], dim)
[M, I] = min(A, [], dim)
M = min(A, [], vecdim)
[M, I] = min(A, [], vecdim)
M = min(A, [], "all")
[M, I] = min(A, [], "all")
M = min(A, [], "linear")
[M, I] = min(A, [], "linear")
M = min(A, [], nanflag)
[M, I] = min(A, [], nanflag)
M = min(A, [], "ComparisonMethod", method)
[M, I] = min(A, [], "ComparisonMethod", method)
M = min(A, B, "ComparisonMethod", method)
M = min(A, [], optionName, optionValue, ...)
[M, I] = min(A, [], optionName, optionValue, ...)
M = min(A, B, optionName, optionValue, ...)

Inputs

A
Type
Any
Required
Yes
Description
Input scalar or array.
B
Type
Any
Required
Yes
Description
Second operand for element-wise minimum.
placeholder
Type
Any
Required
No
Default
[]
Description
Empty placeholder selecting reduction-argument grammar.
dim
Type
Any
Required
No
Description
Reduction dimension selector (scalar or dimension vector).
flag
Type
StringScalar
Required
No
Description
Reduction mode flag: "all" or "linear".
nanflag
Type
StringScalar
Required
No
Default
"includenan"
Description
Missing-value mode: "includenan" or "omitnan".
optionName
Type
StringScalar
Required
No
Default
"ComparisonMethod"
Description
Option name (currently "ComparisonMethod").
method
Type
StringScalar
Required
No
Default
"auto"
Description
Comparison method: "auto", "abs"/"magnitude", or "real".
optionName
Type
StringScalar
Required
Variadic
Description
Name-value option name.
optionValue
Type
Any
Required
Variadic
Description
Name-value option value.
NameTypeRequiredDefaultDescription
AAnyYes—Input scalar or array.
BAnyYes—Second operand for element-wise minimum.
placeholderAnyNo[]Empty placeholder selecting reduction-argument grammar.
dimAnyNo—Reduction dimension selector (scalar or dimension vector).
flagStringScalarNo—Reduction mode flag: "all" or "linear".
nanflagStringScalarNo"includenan"Missing-value mode: "includenan" or "omitnan".
optionNameStringScalarNo"ComparisonMethod"Option name (currently "ComparisonMethod").
methodStringScalarNo"auto"Comparison method: "auto", "abs"/"magnitude", or "real".
optionNameStringScalarVariadic—Name-value option name.
optionValueAnyVariadic—Name-value option value.

Returns

M
Type
NumericArray
Description
Minimum values.
I
Type
NumericArray
Description
One-based minimum indices/origins.
NameTypeDescription
MNumericArrayMinimum values.
INumericArrayOne-based minimum indices/origins.

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

Errors

RunMat:min:InvalidArgument
When
Argument grammar, dimensions, or option names/values are invalid.
Message
min: invalid argument
RunMat:min:InvalidInput
When
Input values cannot be converted to supported min domains.
Message
min: invalid input
RunMat:min:SizeMismatch
When
Element-wise operands are not broadcast-compatible.
Message
min: size mismatch
RunMat:min:Internal
When
Execution fails due to gather, provider, allocation, or conversion internals.
Message
min: internal failure
IdentifierWhenMessage
RunMat:min:InvalidArgumentArgument grammar, dimensions, or option names/values are invalid.min: invalid argument
RunMat:min:InvalidInputInput values cannot be converted to supported min domains.min: invalid input
RunMat:min:SizeMismatchElement-wise operands are not broadcast-compatible.min: size mismatch
RunMat:min:InternalExecution fails due to gather, provider, allocation, or conversion internals.min: internal failure

Reduction and pairwise forms

min(A) finds each column's minimum in a matrix, with one-based indices available as a second output. min(A,[],dim) chooses an axis; min(A,[],vecdim) chooses several. all and linear select a minimum over every element and a linear index when requested.

min(A,B) compares compatible operands elementwise using implicit expansion. This pairwise form has exactly one output; it does not return an origin index. An empty second argument switches to the reduction form.

By default, includenan propagates the first NaN in a slice. omitnan skips NaNs; an all-NaN slice yields NaN value and index. Missing-value flags are reduction-only, not pairwise controls.

Classes and ordering

Real integer minimum values preserve their exact input class, including wide uint64 values; indices are one-based double values. Real single and double values retain their numerical class. Logical values enter the numeric comparison domain and return double values.

For complex input, the default ComparisonMethod orders by magnitude with phase tie-breaking. real orders by real components; abs or magnitude explicitly select magnitude ordering. These name-value controls are decoded by the same typed owner grammar used by runtime comparison.

GPU and compilation

Supported resident reductions use the owning provider's minimum hooks. A requested mode that the provider cannot execute can gather for host calculation; this changes residency and must not be mistaken for a resident result. Integer class and index behavior remain part of the reduction contract.

The fusion planner can use the minimum reduction kernel for admitted forms. Static analysis leaves the call dynamic when the second operand might be an empty reduction placeholder or a nonempty pairwise operand.

Examples

Minimum and index by column

A = [3 1 5;4 2 6];
[m,idx] = min(A)

Expected output:

m = [3 1 5]; idx = [1 1 1]

Minimum along rows

A = [3 1 5;4 2 6];
[m,idx] = min(A,[],2)

Expected output:

m = [1; 2]; idx = [2; 2]

Global minimum and linear index

A = reshape(1:12,[3 4]);
[m,idx] = min(A,[],'all')

Expected output:

m = 1; idx = 1

Ignore NaNs during reduction

values = [NaN 4 2;3 NaN 1];
[m,idx] = min(values,[],1,'omitnan')

Expected output:

m = [3 4 1]; idx = [2 1 2]

Pairwise minimum with implicit expansion

A = [1 4 7];
B = [2;3;5];
C = min(A,B)

Expected output:

C = [1 2 2; 1 3 3; 1 4 5]

Complex magnitude and real ordering

Z = [1+2i,2+1i,-2+2i];
M = min(Z);
R = min(Z,[],'ComparisonMethod','real')

Expected output:

M = 2+1i; R = -2+2i

Using min with coding agents

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

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

FAQ

How can I request a global minimum's linear index?⌄

Use [m,idx] = min(A,[],'all') or min(A,[],'linear'). The index is one-based in column-major order.

Does pairwise min return an origin index?⌄

No. min(A,B) has one output. A second output belongs to reduction forms such as min(A,[],dim).

How are complex values compared?⌄

The default orders by magnitude with phase tie-breaking; ComparisonMethod can select real, abs, or magnitude.

What if all values are NaN in omitnan mode?⌄

The reduction returns NaN for both value and index in that slice.

Can I mix pairwise comparison with dimension reduction?⌄

No. Use min(A,B) for pairwise comparison or min(A,[],dim) to reduce one array.

Do all modes run on a GPU?⌄

No. Supported provider forms stay resident; unsupported modes can gather for host execution.

Do integers lose precision in min?⌄

Real integer minima preserve native integer class and exact comparisons, including wide values. Indices are double.

Related Math functions

Reduction

all · any · bounds · cummax · cummin · cumprod · cumsum · cumtrapz · diff · gradient · max · maxk · mean · median · mink · movmax · movmean · movmedian · movmin · movprod · movstd · movsum · movvar · nnz · prod · rms · std · sum · trapz · var

Elementwise

abs · angle · besselj · bsxfun · complex · conj · double · eps · erf · erfcinv · exp · expm1 · flintmax · gamma · gammaln · heaviside · hypot · imag · int16 · int32 · int64 · int8 · intmax · intmin · ldivide · log · log10 · log1p · log2 · minus · nextpow2 · plus · pow2 · power · rdivide · real · realmax · realmin · realsqrt · rescale · sign · single · sqrt · times · typecast · uint16 · uint32 · uint64 · uint8

Optim

acceptancesa · annealingboltz · annealingfast · coneprog · crossoverarithmetic · crossoverheuristic · crossoverintermediate · crossoverlaplace · crossoverscattered · crossoversinglepoint · crossovertwopoint · eqnproblem · EquationProblem.solve · EquationProblem.subsasgn · EquationProblem.subsref · evaluate · fgoalattain · fitscalingprop · fitscalingrank · fitscalingshiftlinear · fitscalingtop · fminbnd · fmincon · fminimax · fminsearch · fminunc · fseminf · fsolve · fzero · ga · gacreationlinearfeasible · gacreationnonlinearfeasible · gacreationsobol · gacreationuniform · gacreationuniformint · gaplotbestf · gaplotbestindiv · gaplotdistance · gaplotexpectation · gaplotgenealogy · gaplotmaxconstr · gaplotrange · gaplotscorediversity · gaplotscores · gaplotselection · gaplotstopping · integerConstraint · integral · intlinprog · linprog · lsqcurvefit · lsqlin · LsqlinWarmStart.subsasgn · LsqlinWarmStart.subsref · lsqnonlin · lsqnonneg · mutationadaptfeasible · mutationgaussian · mutationpositivebasis · mutationpower · mutationuniform · optimexpr · optimget · OptimizationConstraint.evaluate · OptimizationConstraint.subsasgn · OptimizationConstraint.subsref · OptimizationExitflag.double · OptimizationExitflag.eq · OptimizationExitflag.ne · OptimizationExitflag.string · OptimizationExpression.acos · OptimizationExpression.acosh · OptimizationExpression.acot · OptimizationExpression.acoth · OptimizationExpression.acsc · OptimizationExpression.acsch · OptimizationExpression.asec · OptimizationExpression.asech · OptimizationExpression.asin · OptimizationExpression.asinh · OptimizationExpression.atan · OptimizationExpression.atanh · OptimizationExpression.cat · OptimizationExpression.cos · OptimizationExpression.cosh · OptimizationExpression.cot · OptimizationExpression.coth · OptimizationExpression.csc · OptimizationExpression.csch · OptimizationExpression.ctranspose · OptimizationExpression.cumprod · OptimizationExpression.cumsum · OptimizationExpression.diag · OptimizationExpression.diff · OptimizationExpression.dot · OptimizationExpression.eq · OptimizationExpression.evaluate · OptimizationExpression.exp · OptimizationExpression.ge · OptimizationExpression.horzcat · OptimizationExpression.ldivide · OptimizationExpression.le · OptimizationExpression.log · OptimizationExpression.mean · OptimizationExpression.minus · OptimizationExpression.mldivide · OptimizationExpression.mpower · OptimizationExpression.mrdivide · OptimizationExpression.mtimes · OptimizationExpression.norm · OptimizationExpression.plus · OptimizationExpression.power · OptimizationExpression.prod · OptimizationExpression.rdivide · OptimizationExpression.reshape · OptimizationExpression.sec · OptimizationExpression.sech · OptimizationExpression.sin · OptimizationExpression.sinh · OptimizationExpression.sqrt · OptimizationExpression.subsasgn · OptimizationExpression.subsref · OptimizationExpression.sum · OptimizationExpression.tan · OptimizationExpression.tanh · OptimizationExpression.times · OptimizationExpression.trace · OptimizationExpression.transpose · OptimizationExpression.uminus · OptimizationExpression.uplus · OptimizationExpression.vertcat · OptimizationExpression.zeros · OptimizationExpression.zerosLike · OptimizationProblem.solve · OptimizationProblem.subsasgn · OptimizationProblem.subsref · OptimizationVariable.subsasgn · OptimizationVariable.subsref · optimoptions · optimplotconstrviolation · optimplotfirstorderopt · optimplotfunccount · optimplotfval · optimplotfvalconstr · optimplotmilp · optimplotstepsize · optimplotx · optimproblem · optimset · optimvar · optimwarmstart · particleswarm · patternsearch · psplotbestf · psplotbestx · psplotfuncount · psplotmaxconstr · psplotmeshsize · pswcreationuniform · pswplotbestf · quad · quadprog · QuadprogWarmStart.subsasgn · QuadprogWarmStart.subsref · saplotbestf · saplotbestx · saplotf · saplotstopping · saplottemperature · saplotx · savemilpsolutions · secondordercone · selectionremainder · selectionroulette · selectionstochunif · selectiontournament · selectionuniform · simulannealbnd · solve · surrogateopt · surrogateoptplot · temperatureboltz · temperatureexp · temperaturefast

Trigonometry

acos · acosd · acosh · acotd · acscd · asecd · asin · asind · asinh · atan · atan2 · atan2d · atand · atanh · cos · cosd · cosh · cospi · deg2rad · pol2cart · rad2deg · sin · sind · sinh · sinpi · tan · tand · tanh

Structure

bandwidth · isdiag · ishermitian · issymmetric · istril · istriu · symrcm

Bitwise

bitand · bitcmp · bitget · bitor · bitset · bitshift · bitxor · swapbytes

Signal

blackman · butter · buttord · cheb2ord · conv · conv2 · deconv · downsample · envelope · filter · filtfilt · fir1 · freqz · gauspuls · hamming · hann · hilbert · periodogram · pulstran · pwelch · rectpuls · resample · sawtooth · sinc · spectrogram · square · tripuls · unwrap · upsample · zplane

Rounding

ceil · fix · floor · mod · rem · round

Factor

chol · decomposition · decomposition.ctranspose · decomposition.mldivide · decomposition.mrdivide · decomposition.mtimes · decomposition.rdivide · decomposition.subsref · decomposition.times · decomposition.uminus · decomposition.uplus · eig · eigs · gmres · ichol · ilu · lu · ordeig · ordqz · ordschur · pcg · qr · qz · rsf2csf · schur · svd

Solve

cond · det · inv · linsolve · norm · null · pinv · rank · rcond · rref · vecnorm

Ops

cross · ctranspose · dot · mldivide · mpower · mrdivide · mtimes · pagemtimes · pagetranspose · trace · transpose

Symbolic

digits · int · limit · piecewise · sym · syms · vpa

Discrete

factor · factorial · gcd · isprime · lcm · primes

Fft

fft · fft2 · fftn · fftshift · ifft · ifft2 · ifftn · ifftshift

Interpolation

griddedInterpolant · griddedInterpolant.subsref · interp1 · interp1q · interp2 · pchip · ppval · spline

Integer Division

idivide

Ode

ode15s · ode23 · ode45 · odeset

Poly

poly · polyder · polyfit · polyint · polyval · roots

Source you can read

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

  • View the source for min 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
  • Reduction and pairwise forms
  • Classes and ordering
  • GPU and compilation
  • Examples
  • Minimum and index by column
  • Minimum along rows
  • Global minimum and linear index
  • Ignore NaNs during reduction
  • Pairwise minimum with implicit expansion
  • Complex magnitude and real ordering
  • Using min with coding agents
  • FAQ
  • Related Math functions
  • Reduction
  • Elementwise
  • Optim
  • Trigonometry
  • Structure
  • Bitwise
  • Signal
  • Rounding
  • Factor
  • Solve
  • Ops
  • Symbolic
  • Discrete
  • Fft
  • Interpolation
  • Integer Division
  • Ode
  • Poly
  • Source you can read
  • About RunMat