hamming
Builtin index · Signal processing
result = hamming(n)
Input: n · Output: result
What it is
n: a number (integer window length).
Overloads
One call shape — this function is not overloaded.
| Code | Input | Output | Description |
result = hamming(n) | n numbernot documented yet | result vector | Returns a length-n real vector. Same raised-cosine family as hann but with coefficients 0.54 - 0.46*cos(...), chosen to minimize the nearest side-lobe (at the cost of slower roll-off). Endpoints are 0.08 exactly, not zero. |
Examples
From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.
amp = db2mag(-6) # amplitude ratio for -6 dB
pow = db2pow(-3) # power ratio for -3 dB
print("db2mag(-6) = {amp}, db2pow(-3) = {pow}")
w_hamming = hamming(8)
w_blackman = blackman(8)
w_kaiser = kaiser(9, 5) # beta=5, odd length so there's an exact center sample
print("hamming[0] = {w_hamming[0]}, blackman[0] = {w_blackman[0]}, kaiser center = {w_kaiser[4]}")
f = logspace(0, 3, 4) # 1, 10, 100, 1000 -- a log-spaced frequency axis
print("logspace(0,3,4) = {f}")
output
db2mag(-6) = 0.501187, db2pow(-3) = 0.501187 hamming[0] = 0.08, blackman[0] = -1.387779e-17, kaiser center = 1 logspace(0,3,4) = [1, 10, 100, 1000]
from signal-processing
How it works
hamming(n) — same raised-cosine family as hann, but with coefficients 0.54 - 0.46*cos(...) chosen to minimize the nearest side-lobe (rather than hann's 0.5/0.5, which gives faster side-lobe roll-off but a higher nearest side-lobe). Same symmetric (n-1) convention as hann. Endpoints are 0.54 - 0.46 = 0.08 exactly, not zero (unlike hann).
From the note above this builtin in the interpreter, where the reasoning was written down as it was built.