SignalUtils.SampleAndDecayFilter Method

procedure SampleAndDecayFilter(Data: TVec; var State: TSampleAndHoldState; Decay: Double);

Filter data with a sample-and-decay filter.

#NameTypeDescription
1DataTVecsource TVec
2StateTSampleAndHoldState
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
uses MtxExpr, Math387, MtxVec, SignalUtils, MtxVecTee, MtxVecEdit,OptimalFir;

procedure TForm1.Button1Click(Sender: TObject);
var b,c: Vector;
n,i: integer;
State: TSampleAndHoldState;
begin
    Tone(b,300,5.0/300,0,1);
    c.Copy(b);
    n := 10;
    for i := 0 to b.Length div n-1 do
begin
    b.SetSubRange(i*n,n);
    SampleAndDecayFilter(b,State,0.95);
end;
b.SetFullRange;
DrawIt([c,b],['Unfiltered','Filtered']);
end;
See Also: SignalUtils.MedianFilter, SignalUtils.SampleAndHoldFilter, SignalUtils.MovingAverageFilter, SignalUtils.ExpAverageFilter