Programmer Guide/Command Reference/EVAL/window: Difference between revisions
From STX Wiki
< Programmer Guide | Command Reference | EVAL
Jump to navigationJump to search
No edit summary |
No edit summary |
||
(5 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
{{DISPLAYTITLE:{{SUBPAGENAME}}}} | {{DISPLAYTITLE:{{SUBPAGENAME}}}} | ||
Compute a window function used for signal windowing in signal processing algorithms. | Compute a window function used for signal windowing in signal processing algorithms. | ||
;Usage: <code>window(<var>type</var>, <var>x</var> {, <var>scale</var> {, <var>par</var>}})</code> | |||
;Usage: | |||
:;<var>type</var>: selects the type of the window function (described below); must be number | :;<var>type</var>: selects the type of the window function (described below); must be number | ||
:;<var>x</var>: | :;<var>x</var>: | ||
Line 11: | Line 10: | ||
:;<var>par</var>: A window parameter depending on the type of the window function (described below). If ''par'' is set to '''0''' (default), a default parameter value is automatically selected. | :;<var>par</var>: A window parameter depending on the type of the window function (described below). If ''par'' is set to '''0''' (default), a default parameter value is automatically selected. | ||
:;Description: The following table shows the implemented window functions and the meaning of the parameter ''par''. For the most types an alias function is implement, which is also shown in the table. In the column description w[i] is the i-th value of the window function (i = 0..n-1) and n is the window length. | :;Description: The following table shows the implemented window functions and the meaning of the parameter ''par''. For the most types an alias function is implement, which is also shown in the table. In the column description w[i] is the i-th value of the window function (i = 0..n-1) and n is the window length. | ||
::{| | ::{| | ||
! ''type'' !! name !! ''par'' !! alias function !! description | ! ''type'' !! name !! ''par'' !! alias function !! description | ||
|- | |- | ||
| 0 || '''rectangle''' || not used || | | 0 || '''rectangle''' || not used || || <pre>w[i] = 1</pre> | ||
|- | |- | ||
| 1 || '''hanning''' || not used || <code>whanning(''x''{,''scale''})</code> | | 1 || '''hanning''' || not used || <code>whanning(''x''{,''scale''})</code> | ||
Line 25: | Line 23: | ||
with: a = 2 * pi / (n-1)</pre> | with: a = 2 * pi / (n-1)</pre> | ||
|- | |- | ||
| 3 || '''blackman''' || 0<''par'' | | 3 || '''blackman''' || 0<''par''≤0.25<BR>default=0.16 || <code>wblackman(''x''{,''scale''{,''par''}})</code> | ||
| <pre>w[i] = (1-par)/2 - 0.5 * cos( a*i ) + par/2 * cos( 2*a*i ) | | <pre>w[i] = (1-par)/2 - 0.5 * cos( a*i ) + par/2 * cos( 2*a*i ) | ||
with: a = 2 * pi / (n-1)</pre> | with: a = 2 * pi / (n-1)</pre> | ||
Line 35: | Line 33: | ||
|- | |- | ||
| 5 || '''bartlett'''<BR>(triangle) || not used || <code>wbartlett(''x''{,''scale''})</code> | | 5 || '''bartlett'''<BR>(triangle) || not used || <code>wbartlett(''x''{,''scale''})</code> | ||
| <pre>0 | | <pre>0 ≤ i ≤ m: w[i] = i / m | ||
m < i < n: w[i] = 2 - i / m | m < i < n: w[i] = 2 - i / m | ||
with: m = (n-1) / 2</pre> | with: m = (n-1) / 2</pre> | ||
|- | |- | ||
| 6 || '''tappered rectangle''' || not used || <code>wtaprect(''x''{,''scale''})</code> | | 6 || '''tappered rectangle''' || not used || <code>wtaprect(''x''{,''scale''})</code> | ||
| | | A rectangle with to short hanning slopes. | ||
|- | |- | ||
| 7 || '''nuttall''' || not used || <code>wnuttall(''x''{,''scale''})</code> | | 7 || '''nuttall''' || not used || <code>wnuttall(''x''{,''scale''})</code> | ||
Line 48: | Line 46: | ||
| A 5-term blackman-harris window with high dynamic range, low frequency resolution and minimized passband ripple (< 0.01dB). Flat-top windows are primarily used for calibration purposes. | | A 5-term blackman-harris window with high dynamic range, low frequency resolution and minimized passband ripple (< 0.01dB). Flat-top windows are primarily used for calibration purposes. | ||
|- | |- | ||
| 9 || '''gauss''' || 0<''par'' | | 9 || '''gauss''' || 0<''par''≤ 20<BR>default=3 || <code>wgauss(''x''{,''scale''{,''par''}})</code> | ||
| <pre>w[i] = exp( -0.5 * (par * (m - i) / m) ^ 2 ) | | <pre>w[i] = exp( -0.5 * (par * (m - i) / m) ^ 2 ) | ||
with: m = (n-1) / 2</pre> | with: m = (n-1) / 2</pre> | ||
|- | |- | ||
|} | |} | ||
::Notes: | ::Notes: | ||
::*If the argument ''type'' has an invalid value, the rectangle window is used. | ::*If the argument ''type'' has an invalid value, the rectangle window is used. | ||
::*If the energy-correction is enabled (argument ''scale''!=0), the values w[i] scaled by a factor that approximately equalises the energy loss caused by the window function. The scaling factor is computed using white noise as test signal. | ::*If the energy-correction is enabled (argument ''scale''!=0), the values w[i] scaled by a factor that approximately equalises the energy loss caused by the window function. The scaling factor is computed using white noise as test signal. | ||
::*If the argument ''par'' is supplied to a function not using this argument, it is ignored. | ::*If the argument ''par'' is supplied to a function not using this argument, it is ignored. | ||
;Result: The result ''r'' depends on the argument ''x'': | ;Result: The result ''r'' depends on the argument ''x'': | ||
:*x is a number: The value is used as window length ''n''. The result ''r'' is vector with length ''n'' containing the window function. | :*x is a number: The value is used as window length ''n''. The result ''r'' is vector with length ''n'' containing the window function. | ||
:*x is a vector or matrix: The number of rows of ''x'' is used as window length. Each column of ''x'' is multiplied with the window function (element-wise) and stored in a column of ''r''. The result ''r'' has the same type as ''x''. | :*x is a vector or matrix: The number of rows of ''x'' is used as window length. Each column of ''x'' is multiplied with the window function (element-wise) and stored in a column of ''r''. The result ''r'' has the same type as ''x''. | ||
;See also: [[../fft|fft]], [[../wconvert|wconvert]], [[../hth|hth]] | |||
[[../#Functions|<function list>]] | |||
Latest revision as of 19:02, 21 April 2011
Compute a window function used for signal windowing in signal processing algorithms.
- Usage
window(type, x {, scale {, par}})
- type
- selects the type of the window function (described below); must be number
- x
-
- If x is a scalar, the argument is used as window length and the result of window is a vector containing the window function.
- If x is a vector or matrix, the number of rows of x is used as window length and the result of window is a matrix with the same dimensions as x where each column contains the windowed values of the input column.
- The window length must be greater than 2!
- scale
- A boolean argument to enable/disable energy correction. If the energy correction is enabled (scale!=0), the window function is scaled by a factor that approximately equalises the energy loss caused by the windowing. To preserve signal energy, scale should be set to 1, otherwise (to preserve signal amplitude) it should be 0.
- par
- A window parameter depending on the type of the window function (described below). If par is set to 0 (default), a default parameter value is automatically selected.
- Description
- The following table shows the implemented window functions and the meaning of the parameter par. For the most types an alias function is implement, which is also shown in the table. In the column description w[i] is the i-th value of the window function (i = 0..n-1) and n is the window length.
type name par alias function description 0 rectangle not used w[i] = 1
1 hanning not used whanning(x{,scale})
w[i] = 0.5 - 0.5 * cos( a*i ) with: a = 2 * pi / (n-1)
2 hamming not used whamming(x{,scale})
w[i] = 0.54 - 0.46 * cos( a*i ) with: a = 2 * pi / (n-1)
3 blackman 0<par≤0.25
default=0.16wblackman(x{,scale{,par}})
w[i] = (1-par)/2 - 0.5 * cos( a*i ) + par/2 * cos( 2*a*i ) with: a = 2 * pi / (n-1)
4 kaiser 0<par
default=8wkaiser(x{,scale{,par}})
w[i] = I0( par / m * sqrt(m^2 - (i-m)^2) ) / I0( par ) with: m = (n-1) / 2 I0(z) is the modfied zero-order bessel function
5 bartlett
(triangle)not used wbartlett(x{,scale})
0 ≤ i ≤ m: w[i] = i / m m < i < n: w[i] = 2 - i / m with: m = (n-1) / 2
6 tappered rectangle not used wtaprect(x{,scale})
A rectangle with to short hanning slopes. 7 nuttall not used wnuttall(x{,scale})
A 4-term blackman-harris window with high dynamic range, low frequency resolution and minimized maximum sidelobes.
Nuttall, Albert H. "Some Windows with Very Good Sidelobe Behavior." IEEE Transactions on Acoustics, Speech, and Signal Processing. Vol. ASSP-29 (February 1981). pp. 84-918 flat-top not used wflattop(x{,scale})
A 5-term blackman-harris window with high dynamic range, low frequency resolution and minimized passband ripple (< 0.01dB). Flat-top windows are primarily used for calibration purposes. 9 gauss 0<par≤ 20
default=3wgauss(x{,scale{,par}})
w[i] = exp( -0.5 * (par * (m - i) / m) ^ 2 ) with: m = (n-1) / 2
- Notes:
- If the argument type has an invalid value, the rectangle window is used.
- If the energy-correction is enabled (argument scale!=0), the values w[i] scaled by a factor that approximately equalises the energy loss caused by the window function. The scaling factor is computed using white noise as test signal.
- If the argument par is supplied to a function not using this argument, it is ignored.
- Notes:
- Result
- The result r depends on the argument x:
- x is a number: The value is used as window length n. The result r is vector with length n containing the window function.
- x is a vector or matrix: The number of rows of x is used as window length. Each column of x is multiplied with the window function (element-wise) and stored in a column of r. The result r has the same type as x.