Provides infinite impulse response (IIR) filters
More...
|
| static double [][] | Butterworth (double fc, double fs, int poles, bool isHP) |
| | Returns the normalized recursion coefficents of a Butterworth filter More...
|
| |
| static double [][] | Chebyshev (double fc, double fs, double ripple, int poles, bool isHP) |
| | Returns the normalized recursion coefficents of a Type-I Chebyshev filter design More...
|
| |
| static double [][] | CombineStages (double[][] ZCoef1, double[][] ZCoef2, bool parallel) |
| | Combines the recursion coefficients of cascade or parallel stages into a single system More...
|
| |
| static double [][] | DC_Removal () |
| | Returns the recursion coefficients of a DC removal filter More...
|
| |
| static double [] | Filter (double[] A, double[][] ZCoef) |
| | Recursive operation used to filter data using the specified recursion coefficients More...
|
| |
| static double [][] | Narrow_BP (double fcenter, double bw, double fs) |
| | Returns the recursion coefficients of a two-pole narrow band pass filter More...
|
| |
| static double [][] | Narrow_BR (double fcenter, double bw, double fs) |
| | Returns the recursion coefficients of a two-pole narrow band stop filter More...
|
| |
| static double [][] | SinglePole_HP (double fc, double fs) |
| | Returns the recursion coefficients of a single pole high pass filter More...
|
| |
| static double [][] | SinglePole_LP (double fc, double fs) |
| | Returns the recursion coefficients of a single pole low pass filter More...
|
| |
Provides infinite impulse response (IIR) filters
◆ Butterworth()
| static double [][] dsp.IIR.Butterworth |
( |
double |
fc, |
|
|
double |
fs, |
|
|
int |
poles, |
|
|
bool |
isHP |
|
) |
| |
|
static |
Returns the normalized recursion coefficents of a Butterworth filter
Butterworth filter is a filter with zero ripple (maximmaly flat)
- Parameters
-
| fc | cut-off frequency measured at an amplitude of 0.707 (-3dB), given in Hertz |
| fs | sampling rate (Hz) |
| poles | number of poles must be an even number from two till eight (2..8) |
| isHP | low pass (false), high pass (true) |
◆ Chebyshev()
| static double [][] dsp.IIR.Chebyshev |
( |
double |
fc, |
|
|
double |
fs, |
|
|
double |
ripple, |
|
|
int |
poles, |
|
|
bool |
isHP |
|
) |
| |
|
static |
Returns the normalized recursion coefficents of a Type-I Chebyshev filter design
When the filter type is low-pass the returned coefficients have unity gain at DC.
When the filter type is high-pass the coefficients have unity gain at the maximum frequency (0.5).
- Parameters
-
| fc | cut-off frequency measured at an amplitude of 0.707 (-3dB), given in Hertz |
| fs | sampling rate (Hz) |
| ripple | the percent ripple in the pass-band (max 30) |
| poles | number of poles must be an even number from two till eight (2..8) |
| isHP | low pass (false), high pass (true) |
Example
double[][] lp = IIR.Chebyshev(20, 200, 0.5, 4, false);
Console.WriteLine(NArray.ToString(lp[0]));
Console.WriteLine(NArray.ToString(lp[1]));
0.00278075686761849 0.011123027470474 0.016684541205711 0.011123027470474 0.00278075686761849
0 2.76403050470442 -3.12285267835854 1.66455302410543 -0.350222960333201
◆ CombineStages()
| static double [][] dsp.IIR.CombineStages |
( |
double |
ZCoef1[][], |
|
|
double |
ZCoef2[][], |
|
|
bool |
parallel |
|
) |
| |
|
static |
Combines the recursion coefficients of cascade or parallel stages into a single system
- Parameters
-
| ZCoef1 | recursion coefficients |
| ZCoef2 | recursion coefficients |
| parallel | cascade (false) or parallel (true) combination |
Example
The example bellow combines the recursion coefficients of a two stage single pole low pass filter into a single system having two poles.
double[][] lp = IIR.SinglePole_LP(5, 200);
double[][] lp2 = IIR.CombineStages(lp, lp, false);
Console.WriteLine(NArray.ToString(lp2[0], ", "));
Console.WriteLine(NArray.ToString(lp2[1], ", "));
0.0211306927421788 0 0
0 1.70927199830647 -0.730402691048646
◆ DC_Removal()
| static double [][] dsp.IIR.DC_Removal |
( |
| ) |
|
|
static |
Returns the recursion coefficients of a DC removal filter
◆ Filter()
| static double [] dsp.IIR.Filter |
( |
double [] |
A, |
|
|
double |
ZCoef[][] |
|
) |
| |
|
static |
Recursive operation used to filter data using the specified recursion coefficients
ZCoef[0] holds the a coefficients, while ZCoef[1] holds the b coefficients.
Notes:
If custom coefficients are used assign a zero value to b0 coefficient (Zcoef[1][0] = 0), since ZCoef[0] and ZCoef[1] arrays must have an equal size (N).
If the same filter is to be used to more than one signal, run the function that return the coefficients just once, and apply the filter function per signal.
- Parameters
-
| A | real array |
| ZCoef | recursion coefficients |
- Returns
![$\displaystyle y[n]=a_0{x}[n]+a_1{x}[n-1]+...+b_1{y}[n-1]+b_2{y}[n-2]+...$](form_99.png)
Example
The following example shows how to filter a real signal (A) using a single pole low pass filter.
double[] A = new double[] { 3, 7, -2, 1, -5, 3, 9, 4 };
double[][] cf = IIR.SinglePole_LP(2, 6);
double[] res = IIR.Filter(A, cf);
res = NArray.Round(res, 2);
Console.WriteLine(NArray.ToString(res));
2.63 6.46 -0.96 0.76 -4.29 2.1 8.15 4.51
◆ Narrow_BP()
| static double [][] dsp.IIR.Narrow_BP |
( |
double |
fcenter, |
|
|
double |
bw, |
|
|
double |
fs |
|
) |
| |
|
static |
Returns the recursion coefficients of a two-pole narrow band pass filter
- Parameters
-
| fcenter | center frequency (Hz) |
| bw | bandwidth measured at -3dB, given in Hertz |
| fs | sampling rate (Hz) |
Example
double[][] bp = IIR.Narrow_BP(25,2, 200);
Console.WriteLine(NArray.ToString(bp[0]));
Console.WriteLine(NArray.ToString(bp[1]));
0.0284636038969323 0.00217279220613561 -0.0306363961030678
0 1.3717871555019 -0.9409
◆ Narrow_BR()
| static double [][] dsp.IIR.Narrow_BR |
( |
double |
fcenter, |
|
|
double |
bw, |
|
|
double |
fs |
|
) |
| |
|
static |
Returns the recursion coefficients of a two-pole narrow band stop filter
- Parameters
-
| fcenter | center frequency (Hz) |
| bw | bandwidth measured at -3dB, given in Hertz |
| fs | sampling rate (Hz) |
Example
double[][] bp = IIR.Narrow_BP(25,2, 200);
Console.WriteLine(NArray.ToString(bp[0]));
Console.WriteLine(NArray.ToString(bp[1]));
0.0284636038969323 0.00217279220613561 -0.0306363961030678
0 1.3717871555019 -0.9409
◆ SinglePole_HP()
| static double [][] dsp.IIR.SinglePole_HP |
( |
double |
fc, |
|
|
double |
fs |
|
) |
| |
|
static |
Returns the recursion coefficients of a single pole high pass filter
- Parameters
-
| fc | cut-off frequency measured at -3dB, given in Hertz |
| fs | sampling rate (Hz) |
Example
double[][] hp = IIR.SinglePole_HP(5, 200);
Console.WriteLine(NArray.ToString(hp[0]));
Console.WriteLine(NArray.ToString(hp[1]));
0.927317999576617 -0.927317999576617
0 0.854635999153233
◆ SinglePole_LP()
| static double [][] dsp.IIR.SinglePole_LP |
( |
double |
fc, |
|
|
double |
fs |
|
) |
| |
|
static |
Returns the recursion coefficients of a single pole low pass filter
- Parameters
-
| fc | cut-off frequency measured at -3dB, given in Hertz |
| fs | sampling rate (Hz) |
Example
double[][] lp = IIR.SinglePole_LP(5, 200);
Console.WriteLine(NArray.ToString(lp[0]));
Console.WriteLine(NArray.ToString(lp[1]));
0.145364000846767 0
0 0.854635999153233