Overload List
| # | Signature | Description |
|---|---|---|
| 1 | void IirFilter(TCplx Src, ref TCplx Dst, ref TIirState IIRState) | Filter data with an IIR filter. |
| 2 | void IirFilter(TSCplx Src, ref TSCplx Dst, ref TIirState IIRState) | |
| 3 | void IirFilter(TVec Data, TVec Num, TVec Den, Boolean LinearPhase) | Filter Data and place the result back in Data. |
| 4 | void IirFilter(TVec Src, TVec Dst, ref TIirState IIRState) | Filter data with an IIR filter. |
| 5 | void IirFilter(TVec Data, ref TIirState IIRState, Boolean LinearPhase) | Filter data with an IIR filter. |
| 6 | void IirFilter(Double Src, ref Double Dst, ref TIirState IIRState) | Filter data with an IIR filter. |
| 7 | void IirFilter(Single Src, ref Single Dst, ref TIirState IIRState) |
Overload 1: void IirFilter(TCplx Src, ref TCplx Dst, ref TIirState IIRState)
Filter data with an IIR filter.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Src | TCplx | scalar |
| 2 | Dst | TCplx (ref) | output |
| 3 | IIRState | TIirState (ref) |
Result: stored in self (calling object)
Filters sample Src and places complex output of the filter in Dst.
Overload 2: void IirFilter(TSCplx Src, ref TSCplx Dst, ref TIirState IIRState)
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Src | TSCplx | scalar |
| 2 | Dst | TSCplx (ref) | |
| 3 | IIRState | TIirState (ref) |
Result: stored in self (calling object)
Overload 3: void IirFilter(TVec Data, TVec Num, TVec Den, Boolean LinearPhase)
Filter Data and place the result back in Data.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Data | TVec | source TVec |
| 2 | Num | TVec | source TVec |
| 3 | Den | TVec | source TVec |
| 4 | LinearPhase | Boolean |
Result: stored in self (calling object)
The Iir filter is defined with a transfer function. Num is numerator and Den is denominator. Set LinearPhase to True to double filter attenuation and ensure no phase distortion and no phase delay (except for the initial transition regions).
using Dew.Math;
using Dew.Math.Editors;
using Dew.Math.Units;
using Dew.Signal;
using Dew.Signal.Units;
using Dew.Math.Tee;
using Dew.Signal.Tee;
private void button1_Click(object sender, EventArgs e)
{
Vector b = new Vector(0);
Vector c = new Vector(0);
Vector num = new Vector(0);
Vector den = new Vector(0);
Vector Response1 = new Vector(0);
Vector Response2 = new Vector(0);
TIirState state = new TIirState();
int n;
int i;
SignalUtils.Tone(b,300,6.0/300,0,1,false);
// Alternative: try gaussian noise
// b = MtxExpr.RandGauss(300);
c.Size(b);
IIRFilters.ChebyshevIFilter(6,0.2,new double[1] {0.6}, TFilterType.ftLowpass,false,num,den,TIirFrequencyTransform.ftStateSpaceAnalog);
SignalUtils.IirInit(num,den,ref state,false);
try
{
//Alternative 1, IIR streaming
n = 10;
int bLength = b.Length; //to prevente reevaluaton inside "for"
for (i = 0; i < (bLength/n); i++)
{
b.SetSubRange(i*n,n);
c.SetSubRange(i*n,n);
SignalUtils.IirFilter(b,c,ref state);
}
}
finally
{
SignalUtils.IirFree(ref state);
}
//Alternative 2 single block filter (does not require TIirState)
// c.Copy(b);
// SignalUtils.IirFilter(c,num,den,true);
//Alternative 3 single block
// c.Copy(b);
// SignalUtils.IirFilter(c,state);
c.SetFullRange();
b.SetFullRange();
MtxVecTee.DrawIt(new TVec[2] {b,c}, new string[2] {"Original signal","Filtered signal"},"Time signals", false);
SignalUtils.FrequencyResponse(c, null, Response1, 1, true, TSignalWindowType.wtHanning, 0);
SignalUtils.FrequencyResponse(b, null, Response2, 1, true, TSignalWindowType.wtHanning, 0);
MtxVecTee.DrawIt(new TVec[2] {Response1,Response2}, new string[2] {"Spectrum: original signal","Spectrum: filtered signal"}, "Frequency spectrum", false);
}
Overload 4: void IirFilter(TVec Src, TVec Dst, ref TIirState IIRState)
Filter data with an IIR filter.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Src | TVec | source TVec |
| 2 | Dst | TVec | source TVec |
| 3 | IIRState | TIirState (ref) |
Result: stored in self (calling object)
Filter data in Src and place the result in Dst. IirState must be initialized with a call to IirInit.
Note
Use this routine for filtering of streaming data.
Overload 5: void IirFilter(TVec Data, ref TIirState IIRState, Boolean LinearPhase)
Filter data with an IIR filter.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Data | TVec | source TVec |
| 2 | IIRState | TIirState (ref) | |
| 3 | LinearPhase | Boolean |
Result: stored in self (calling object)
Filter Data and place the result back in Data. Use this routine for filtering of non-consecutive blocks of data. Set LinearPhase to True to double filter attenuation and ensure no phase distortion and no phase delay.
Overload 6: void IirFilter(Double Src, ref Double Dst, ref TIirState IIRState)
Filter data with an IIR filter.
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Src | Double | scalar |
| 2 | Dst | Double (ref) | output |
| 3 | IIRState | TIirState (ref) |
Result: stored in self (calling object)
Filters sample Src and places real valued output of the filter in Dst.
Overload 7: void IirFilter(Single Src, ref Single Dst, ref TIirState IIRState)
| # | Name | Type | Description |
|---|---|---|---|
| 1 | Src | Single | scalar |
| 2 | Dst | Single (ref) | |
| 3 | IIRState | TIirState (ref) |
Result: stored in self (calling object)