Skip to content

FFT notch filter, off by one bin #17

Description

@ArCourtin

When using the FFT notch filter to remove a given frequency (.25) and harmonics (just one bin each time), the filter removes one bin too early.

I fixed it by making the following changes to CLW_buildFFTfilter:
BEFORE
Line25: x1=fix((option.notch_fre * k+option.notch_width-xstart)/xstep)+1;
Line26: x2=fix((option.notch_fre * k+option.notch_width+option.slope_width-xstart)/xstep)+1;
Line27: v1=FFTfilter_lowpass(x1,x2,header.datasize(6));
Line28:
Line29: x2=fix((option.notch_fre * k-option.notch_width-xstart)/xstep)+1;
Line30: x1=fix((option.notch_fre * k-option.notch_width-option.slope_width-xstart)/xstep)+1;

AFTER
Line25: x1=fix((option.notch_fre * k+option.notch_width-xstart)/xstep)+2;
Line26: x2=fix((option.notch_fre * k+option.notch_width+option.slope_width-xstart)/xstep)+2;
Line27: v1=FFTfilter_lowpass(x1,x2,header.datasize(6));
Line28:
Line29: x2=fix((option.notch_frek-option.notch_width-xstart)/xstep)+2;
Line30: x1=fix((option.notch_fre
k-option.notch_width-option.slope_width-xstart)/xstep)+2;

I also want to point out that line 36 is problematic and leads to an error, as mentioned in previous issue reports.
I think the correct formula should be:
Line36: v((end+1)/2:end)=v(2+(end-1)/2: -1 :2);
Best,
Arthur

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions