blackman — Generate a Blackman window vector in MATLAB and RunMat.
blackman generates a Blackman window from a nonnegative scalar length. The length accepts single, double, or any of the eight built-in integer classes; floating lengths round to the nearest integer.
Syntax
w = blackman(n)
w = blackman(n, sampling)
w = blackman(n, precision)
w = blackman(n, sampling, precision)Inputs
L- Type
SizeArg- Required
- Yes
- Description
- Nonnegative scalar window length.
sflag- Type
StringScalar- Required
- No
- Default
"symmetric"- Description
- Symmetric or periodic sampling.
typeName- Type
StringScalar- Required
- No
- Default
"double"- Description
- Double or single output precision.
Returns
w- Type
NumericArray- Description
- Window column vector.
Errors
RunMat:blackman:InvalidLength- When
- Length is not a supported nonnegative scalar.
- Message
blackman: expected a nonnegative scalar length
RunMat:blackman:InvalidOption- When
- An option is not a scalar text token.
- Message
blackman: unrecognized option
RunMat:blackman:UnknownOption- When
- An option is unrecognized or out of position.
- Message
blackman: unrecognized option
Behavior
blackman(L) returns an L x 1 symmetric Blackman window.
blackman(L, 'periodic') returns the periodic form used in spectral-analysis workflows.
blackman(..., 'single') returns a single-precision window; 'double' is the default.
Length L accepts single, double, int8, int16, int32, int64, uint8, uint16, uint32, or uint64; noninteger floating values round to the nearest integer.
A logical scalar length is available only as an explicitly gated RunMat extension.
blackman(0) returns an empty 0 x 1 tensor.
blackman(1) returns 1.
For the symmetric case and L > 1, coefficients use cospi evaluation of 0.42 - 0.5*cospi(2*n/(L-1)) + 0.08*cospi(4*n/(L-1)), matching the current enhanced-accuracy algorithm.
The periodic form is constructed by evaluating a symmetric window of length L + 1 and dropping the final sample.
Execution
The scalar length is host structural input. When the active provider supports the selected precision, RunMat may create the new window resident on that provider; otherwise it constructs a host window. This is automatic output placement, not an interactive gpuArray length overload.
The window is not fused with adjacent operations. Symmetric and periodic forms use the same cosine-sum coefficients; periodic sampling omits the final point of a length L + 1 symmetric evaluation.
Examples
Generate a short Blackman window
w = blackman(8);
disp(w')Generate a periodic Blackman window
w = blackman(8, 'periodic');
disp(w')Generate a single-precision Blackman window
w = blackman(8, 'single');
class(w)Using blackman with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how blackman changes the result.
Run a small blackman example, explain the result, then change one input and compare the output.
FAQ
Why would I use blackman instead of hann or hamming?⌄
A Blackman window is often used when you want lower spectral leakage at the cost of a wider main lobe. It is a common tradeoff choice in spectral analysis workflows.
What is the difference between the symmetric and periodic Blackman window?⌄
Use the symmetric form for filter-design style workflows. Use 'periodic' for FFT-based spectral analysis, where RunMat constructs a symmetric window of length L + 1 and removes the final sample.
Does blackman support single precision?⌄
Yes. Pass 'single' as the final option to request a single-precision output. The default output type is double precision.
Does an integer length produce an integer window?⌄
No. Every integer length class is a structural input; output is double by default or single when requested explicitly.
Does blackman accept a gpuArray input?⌄
No interactive gpuArray input form exists because the only numeric input is a host scalar length. GPU code generation is a separate documented capability; RunMat may internally materialize the new floating window on its active provider.
Related Math functions
Signal
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
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
Reduction
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
Structure
bandwidth · isdiag · ishermitian · issymmetric · istril · istriu · symrcm
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
Ops
cross · ctranspose · dot · mldivide · mpower · mrdivide · mtimes · pagemtimes · pagetranspose · trace · transpose
Interpolation
griddedInterpolant · griddedInterpolant.subsref · interp1 · interp1q · interp2 · pchip · ppval · spline
Integer Division
Source you can read
Every RunMat function's source is public. Read exactly how blackman is executed, line by line, in Rust.
- View the source for blackman 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.