1math::filters(n) Tcl Math Library math::filters(n)
2
3
4
5______________________________________________________________________________
6
8 math::filters - Digital filters
9
11 package require Tcl 8.6
12
13 package require TclOO
14
15 package require math::filters ?0.1?
16
17 ::math::filters::filterButterworth lowpass order samplefreq cutofffreq
18
19 ::math::filters::filter coeffs data
20
21 ::math::filters::filterObj new coeffs yinit
22
23 $filterObj filter x
24
25 $filterObj reset
26
27______________________________________________________________________________
28
30 The math::filters package implements digital filters, notably Butter‐
31 worth low-pass and high-pass filters. The procedures allow to filter an
32 entire data series as well as filter data one by one.
33
35 The package defines the following public procedures:
36
37 ::math::filters::filterButterworth lowpass order samplefreq cutofffreq
38 Determine the coefficients for a Butterworth filter of given or‐
39 der. The coefficients are returned as a list of the x-coeffi‐
40 cients, the y-coefficients and the scale. The formula is (n is
41 the filter order):
42
43
44 n n
45 scale * y_k = sum x_(k-i) + sum y_(k-i)
46 i=0 i=1
47
48
49 bool lowpass
50 Generate a low-pass filter (1) or a high-pass filter (0)
51
52 integer lowpass
53 The order of the filter to be generated
54
55 double samplefreq
56 Sampling frequency of the data series
57
58 double cutofffreq
59 Cut-off frequency for the filter
60
61 ::math::filters::filter coeffs data
62 Filter the entire data series based on the filter coefficients.
63
64 list coeffs
65 List of coefficients as generated by filterButterworth
66 (or in fact any similar list of coefficients)
67
68 list data
69 Data to be filtered
70
71 ::math::filters::filterObj new coeffs yinit
72 Create a filter object. The initial x data are taken as zero.
73 The initial y data can be prescribed. If they are not given,
74 they are taken as zero as well.
75
76 list coeffs
77 List of coefficients as generated by filterButterworth
78 (or in fact any similar list of coefficients)
79
80 list yinit
81 (Optional) initial data for the filter result.
82
83 $filterObj filter x
84 Filter a single value and return the result.
85
86 double x
87 The value to be filtered
88
89 $filterObj reset
90 Reset the filter object (start anew)
91
93 digital, filtering
94
96 Mathematics
97
99 Copyright (c) 2020 by Arjen Markus
100
101
102
103
104tcllib 0.1 math::filters(n)