logo
Free, unlimited AI code reviews that run on commit
git-lrc git-lrc GitHub Install Now We'd appreciate a star git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt git-lrc - Free, unlimited AI code reviews that run on commit | Product Hunt

math::filters - Digital filters

Category

       Mathematics

Description

       The math::filters package implements digital filters, notably Butterworth low-pass and high-pass filters.
       The procedures allow to filter an entire data series as well as filter data one by one.

Keywords

       digital, filtering

Name

       math::filters - Digital filters

Procedures

       The package defines the following public procedures:

       ::math::filters::filterButterworthlowpassordersamplefreqcutofffreq
              Determine  the coefficients for a Butterworth filter of given order. The coefficients are returned
              as a list of the x-coefficients, the y-coefficients and the scale. The formula is (n is the filter
              order):

                                 n             n
                  scale * y_k = sum x_(k-i) + sum y_(k-i)
                                i=0           i=1

              bool lowpass
                     Generate a low-pass filter (1) or a high-pass filter (0)

              integer lowpass
                     The order of the filter to be generated

              double samplefreq
                     Sampling frequency of the data series

              double cutofffreq
                     Cut-off frequency for the filter

       ::math::filters::filtercoeffsdata
              Filter the entire data series based on the filter coefficients.

              list coeffs
                     List of coefficients as generated by filterButterworth (or in  fact  any  similar  list  of
                     coefficients)

              list data
                     Data to be filtered

       ::math::filters::filterObj new coeffsyinit
              Create  a  filter  object.  The  initial  x  data  are  taken  as  zero. The initial y data can be
              prescribed. If they are not given, they are taken as zero as well.

              list coeffs
                     List of coefficients as generated by filterButterworth (or in  fact  any  similar  list  of
                     coefficients)

              list yinit
                     (Optional) initial data for the filter result.

       $filterObj filter x
              Filter a single value and return the result.

              double x
                     The value to be filtered

       $filterObj reset
              Reset the filter object (start anew)

Synopsis

       package require Tcl8.69

       package require TclOO

       package require math::filters?0.3?::math::filters::filterButterworthlowpassordersamplefreqcutofffreq::math::filters::filtercoeffsdata::math::filters::filterObj new coeffsyinit$filterObj filter x$filterObj reset

________________________________________________________________________________________________________________

See Also