SignalUtils.SampleAndHoldFilter Method

void SampleAndHoldFilter(TVec Data, ref TSampleAndHoldState State, Int32 Hold)

Filter data with a sample-and-hold filter.

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

Result: stored in self (calling object)

Remarks:

Filter Data with a non-linear sample-and-hold filter. The current value is held until a bigger is found or time-out occurs. Time out is defined in samples with Hold parameter. The filter features streaming support via the State variable. Data can be real or complex. 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.SampleAndHoldFilter(b,ref State, 7);
    }
    b.SetFullRange();
    MtxVecTee.DrawIt(new TVec[2] {c,b}, new string[2] {"Unfiltered","Filtered"},"SampleAndDecay",false);
}
See Also: SignalUtils.SampleAndDecayFilter, SignalUtils.MedianFilter, SignalUtils.MovingAverageFilter, SignalUtils.ExpAverageFilter