Skip to content

Implement an 1d filter - matlab equivalent #263

@trlef19

Description

@trlef19

I noticed that there is no fir filter equivalent to this one from matlab. I think it would be nice and useful. Here is a c++ equivalent i made and it may be somewhat useful. I know its far from optimized.

   kfr::univector<double> filter1d(const kfr::univector<double>& b,const kfr::univector<double>& x) {
    const auto filter_length = b.size();
    const auto seg_length = x.size();
    kfr::univector filtered(seg_length, 0.0);
    for (auto n = 0; n < seg_length; n++) {
        for (auto k = 0; k < filter_length; k++) {
            if (n >= k)
                filtered[n] += b[k] * x[n - k];
        }
    }
    return filtered;
}

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