SignalUtils.IirFilter Method

Overload List

#SignatureDescription
1void IirFilter(TCplx Src, ref TCplx Dst, ref TIirState IIRState)Filter data with an IIR filter.
2void IirFilter(TSCplx Src, ref TSCplx Dst, ref TIirState IIRState)
3void IirFilter(TVec Data, TVec Num, TVec Den, Boolean LinearPhase)Filter Data and place the result back in Data.
4void IirFilter(TVec Src, TVec Dst, ref TIirState IIRState)Filter data with an IIR filter.
5void IirFilter(TVec Data, ref TIirState IIRState, Boolean LinearPhase)Filter data with an IIR filter.
6void IirFilter(Double Src, ref Double Dst, ref TIirState IIRState)Filter data with an IIR filter.
7void 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.

#NameTypeDescription
1SrcTCplxscalar
2DstTCplx (ref)output
3IIRStateTIirState (ref)

Result: stored in self (calling object)

Remarks:

Filters sample Src and places complex output of the filter in Dst.

Overload 2: void IirFilter(TSCplx Src, ref TSCplx Dst, ref TIirState IIRState)

#NameTypeDescription
1SrcTSCplxscalar
2DstTSCplx (ref)
3IIRStateTIirState (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.

#NameTypeDescription
1DataTVecsource TVec
2NumTVecsource TVec
3DenTVecsource TVec
4LinearPhaseBoolean

Result: stored in self (calling object)

Remarks:

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).

Examples
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);
}
See Also: SignalUtils.SavGolayFilter, OptimalFir.RemezImpulse, SignalUtils.FirInit, SignalUtils.IirInit, SignalUtils.IirFree

Overload 4: void IirFilter(TVec Src, TVec Dst, ref TIirState IIRState)

Filter data with an IIR filter.

#NameTypeDescription
1SrcTVecsource TVec
2DstTVecsource TVec
3IIRStateTIirState (ref)

Result: stored in self (calling object)

Remarks:

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.

#NameTypeDescription
1DataTVecsource TVec
2IIRStateTIirState (ref)
3LinearPhaseBoolean

Result: stored in self (calling object)

Remarks:

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.

#NameTypeDescription
1SrcDoublescalar
2DstDouble (ref)output
3IIRStateTIirState (ref)

Result: stored in self (calling object)

Remarks:

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)

#NameTypeDescription
1SrcSinglescalar
2DstSingle (ref)
3IIRStateTIirState (ref)

Result: stored in self (calling object)