hann — Generate a Hann window as an N-by-1 real column vector.
hann generates Hann windows for signal-processing workflows such as spectral analysis and filter design. RunMat supports the common MATLAB call forms for symmetric and periodic windows, including optional single-precision output.
How hann works in RunMat
hann(L)returns anL x 1symmetric Hann window.hann(L, 'periodic')returns the periodic form used in spectral-analysis workflows.hann(..., 'single')returns a single-precision window;'double'is the default.- If
Lis noninteger, RunMat rounds it to the nearest integer before constructing the window. hann(0)returns an empty0 x 1tensor.hann(1)returns1.- For the symmetric case and
L > 1, coefficients follow0.5 - 0.5*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 Hann window
w = hann(8);
disp(w')Generate a periodic Hann window for spectral analysis
w = hann(8, 'periodic');
disp(w')Generate a single-precision Hann window
w = hann(8, 'single');
class(w)FAQ
What is the difference between the symmetric and periodic Hann window?
Use the default symmetric window for filter-design style workflows. Use 'periodic' for spectral analysis, where MATLAB and RunMat construct a symmetric window of length L + 1 and drop the last sample so the sequence matches the periodicity assumptions of the DFT.
What shape does hann(L) return?
It returns an L x 1 column vector, matching MATLAB's window-function convention.
Does hann support single precision?
Yes. Pass 'single' as the final option to request a single-precision output. The default output type is double precision.
Related functions to explore
These functions work well alongside hann. Each page has runnable examples you can try in the browser.
About RunMat
RunMat is an open-source runtime that executes MATLAB-syntax code — faster, on any GPU, with no license required.
- Simulations that took hours now take minutes. RunMat automatically optimizes your math for GPU execution on Apple, Nvidia, and AMD hardware. No code changes needed.
- Start running code in seconds. Open the browser sandbox or download a single binary. No license server, no IT ticket, no setup.
- A full development environment. GPU-accelerated 2D and 3D plotting, automatic versioning on every save, and a browser IDE you can share with a link.