hamming — Generate Hamming windows in MATLAB and RunMat.
hamming(L) returns an L-by-1 Hamming window. Symmetric and periodic forms follow MATLAB semantics.
Syntax
w = hamming(n)
w = hamming(n, sampling)Inputs
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
n | SizeArg | Yes | — | Window length. |
sampling | StringScalar | No | "symmetric" | Sampling mode: "symmetric" or "periodic". |
Returns
| Name | Type | Description |
|---|---|---|
w | NumericArray | Hamming window column vector. |
Errors
| Identifier | When | Message |
|---|---|---|
RunMat:hamming:InvalidLength | Length input is not a finite nonnegative scalar value. | hamming: expected a nonnegative scalar integer length |
RunMat:hamming:InvalidOption | An option argument is not a string-like sampling token. | hamming: unrecognized option |
RunMat:hamming:UnknownOption | An option string is not recognized by hamming. | hamming: unrecognized option |
RunMat:hamming:InternalError | Window materialization fails internally. | hamming: internal error |
How hamming works
hamming(L)returns anL x 1symmetric Hamming window.hamming(L, 'periodic')returns the periodic form used in spectral-analysis workflows.- If
Lis noninteger, RunMat rounds it to the nearest integer before constructing the window. hamming(0)returns an empty0 x 1tensor.hamming(1)returns1.- For the symmetric case and
L > 1, coefficients follow0.54 - 0.46*cos(2*pi*n/(L-1)). - The periodic form is constructed by evaluating a symmetric window of length
L + 1and dropping the final sample.
Examples
Generate a short Hamming window
w = hamming(8);
disp(w')Generate a periodic Hamming window
w = hamming(8, 'periodic');
disp(w')Using hamming with coding agents
Open a RunMat example with live inputs, then ask the agent to explain how hamming changes the result.
Run a small hamming example, explain the result, then change one input and compare the output.
FAQ
When should I use the periodic Hamming window?⌄
Use 'periodic' when the window will be paired with FFT-based spectral analysis. The periodic form is built from a symmetric window of length L + 1 with the final sample removed.
What shape does hamming(L) return?⌄
It returns an L x 1 column vector.
Does RunMat support a typeName overload for hamming?⌄
RunMat currently implements the documented hamming(L) and hamming(L, sflag) forms.
Related Math functions
Signal
blackman · butter · buttord · conv · conv2 · deconv · downsample · envelope · filter · filtfilt · fir1 · freqz · gauspuls · hann · hilbert · periodogram · pulstran · pwelch · rectpuls · sawtooth · sinc · spectrogram · square · tripuls · unwrap · upsample · zplane
Elementwise
abs · angle · complex · conj · double · exp · expm1 · factorial · gamma · heaviside · hypot · imag · ldivide · log · log10 · log1p · log2 · minus · nextpow2 · plus · pow2 · power · rdivide · real · sign · single · sqrt · times
Trigonometry
acos · acosh · asin · asinh · atan · atan2 · atanh · cos · cosd · cosh · deg2rad · rad2deg · sin · sind · sinh · tan · tand · tanh
Reduction
all · any · cummax · cummin · cumprod · cumsum · cumtrapz · diff · gradient · max · mean · median · min · nnz · prod · std · sum · trapz · var
Structure
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.