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 |
||
Line 27: | Line 27: | ||
|- | |- | ||
| 4 || '''kaiser''' || 0 < ''par''<BR>default=8 || <code>wkaiser(''x'' {, ''scale'' {, ''par''}})</code> | | 4 || '''kaiser''' || 0 < ''par''<BR>default=8 || <code>wkaiser(''x'' {, ''scale'' {, ''par''}})</code> | ||
| <pre>w[i] = I0( ''par''*sqrt(m^2 - (i-m)^2) ) / I0( ''par'' * m ) | | <pre>w[i] = I0( ''par''*sqrt(m^2 - (i-m)^2) ) / I0( ''par'' * m )</pre> | ||
I0(z) is the modfied zero-order bessel function | |||
|- | |- | ||
| 5 || '''bartlett''' || not used || <code>wbartlett(''x'' {, ''scale''})</code> | | 5 || '''bartlett'''<BR>(triangle) || not used || <code>wbartlett(''x'' {, ''scale''})</code> | ||
| <pre> | |||
|- | |- | ||
| 6 || '''tappered rectangle''' || not used || <code>wtaprect(''x'' {, ''scale''})</code> | | 6 || '''tappered rectangle''' || not used || <code>wtaprect(''x'' {, ''scale''})</code> | ||
Line 42: | Line 42: | ||
|- | |- | ||
|} | |} | ||
::Notes: | |||
::* <code>a = 2 * pi / (n - 1)</code> | |||
::* <code>m = (n - 1) / 2</code> | |||
Revision as of 08:21, 7 April 2011
Compute a window function used for signal windowing in sighnal 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.
type name par alias function description 0 rectangle not used 1 hanning not used whanning(x {, scale})
w[i] = 0.5 - 0.5 * cos(2*pi*i/(n-1))
2 hamming not used whamming(x {, scale})
w[i] = 0.54 - 0.46 * cos(2*pi*i/(n-1))
3 blackman 0 < par <= 0.25
default=0.16wblackman(x {, scale {, par}})
w[i] = (1-''par'')/2 - 0.5 * cos(2*pi*i/(n-1)) + ''par''/2 * cos(4*pi*i/(n-1))
4 kaiser 0 < par
default=8wkaiser(x {, scale {, par}})
w[i] = I0( ''par''*sqrt(m^2 - (i-m)^2) ) / I0( ''par'' * m )
I0(z) is the modfied zero-order bessel function
5 bartlett
(triangle)not used wbartlett(x {, scale})
|- | 6 || '''tappered rectangle''' || not used || <code>wtaprect(''x'' {, ''scale''})</code> |- | 7 || '''nut-tall''' || not used || <code>wnuttall(''x'' {, ''scale''})</code> |- | 8 || '''flat-top''' || not used || <code>wflattop(''x'' {, ''scale''})</code> |- | 9 || '''gauss''' || 0 < ''par'' <= 20<BR>default=3 || <code>wgauss(''x'' {, ''scale'' {, ''par''}})</code> |- |} ::Notes: ::* <code>a = 2 * pi / (n - 1)</code> ::* <code>m = (n - 1) / 2</code> ;Result: The result ''r'' is a copy of ''x'' but the values of the elements of r are limited to the boundaries defined by ''lo'' and/or ''hi''. ::''r''<sub>i,j</sub> is set to ''lo'' if x<sub>i,j</sub> is lower than ''lo'' (functions '''limit''' and '''limitlow''') ::''r''<sub>i,j</sub> is set to ''hi'' if x<sub>i,j</sub> is greater than ''hi'' (functions '''limit''' and '''limithigh''') ;See also: [[Programmer_Guide/Command_Reference/EVAL/vsubc|vsubc]], [[Programmer_Guide/Command_Reference/EVAL/select|select]] Example: <pre> #a := eval vv(1,2,3,4,5,4,3,2,1) #b := eval fill(9,0,1) #c := eval limitlow($#a, 3) // -> $#c = { 3 , 3 , 3 , 4 , 5 , 4 , 3 , 3 , 3 } #d := eval limit($#b, 2, 6) // -> $#d[*,0] = { 2 , 2 , 3 , 4 , 5 , 4 , 3 , 2 , 2 } // $#d[*,1] = { 2 , 2 , 2 , 3 , 4 , 5 , 6 , 6 , 6 }
General window functionUsage: window(type, x, scale, par) Parameters: type=0 -> none (square) type=1 -> whanning type=2 -> whamming type=3 -> wblackman type=4 -> wkaiser type=5 -> wbartlett type=6 -> wtaprect type=7 -> wnuttall type=8 -> wflattop type=9 -> wgauss The arguments x, scale and par are the same as above.
arguments: x The window length (scalar, >2), the signal (vector or matrix, nrow(x)>2). If x is a matrix, every column is multiplied with the window. scale The scaling (0=unscaled, 1=scaled for rms(sig) ~ rms(sig * wnd) par optional window parameters
The result is the signal window of length x or the signal multiplied by the window.