SignalUtils.SampleAndDecayFilter Method

void SampleAndDecayFilter(TVec Data, ref TSampleAndHoldState State, Double Decay)

Filter data with a sample-and-decay filter.

#NameTypeDescription
1DataTVecsource TVec
2StateTSampleAndHoldState (ref)
3DecayDoublescalar

Result: stored in self (calling object)

Remarks:

Filter Data with a non-linear sample-and-decay filter. This filter is similar to Sample-And-Hold, except that the held value slowly decays until a bigger is found. The filter features streaming support via State variable. Data can be real or complex. The decay parameter defines how much will the value decay from sample to sample. The State variable has to be initialized with zeros before it is passed to the routine for the first time.

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

    int n = 10;
    int i;
    TSampleAndHoldState State = new TSampleAndHoldState();

    SignalUtils.Tone(b,300,5.0/300,0,1,false);
    c.Copy(b);
    int bLength = b.Length;
    for (i = 0; i < (bLength/n); i++)
    {
        b.SetSubRange(i*n,n);
        SignalUtils.SampleAndDecayFilter(b,ref State,0.95);
    }
    b.SetFullRange();
    MtxVecTee.DrawIt(new TVec[2] {c,b}, new string[2] {"Unfiltered","Filtered"},"SampleAndDecay",false);
}
See Also: SignalUtils.MedianFilter, SignalUtils.SampleAndHoldFilter, SignalUtils.MovingAverageFilter, SignalUtils.ExpAverageFilter