Skip to content

Instantly share code, notes, and snippets.

@GaryLee
Created October 28, 2024 07:10
Show Gist options
  • Save GaryLee/3d6b84f2e72b4072ffc07e45919a5330 to your computer and use it in GitHub Desktop.
Save GaryLee/3d6b84f2e72b4072ffc07e45919a5330 to your computer and use it in GitHub Desktop.
How to calculate the coefficient of low-pass filter of z-domain?
#!python
from math import pi
# The first-order low-pass filter has following transfer function of s-domain
# H(s) = a / (s + a).
# Its pole is s = −a, and the pole in digital filter will be z = e^−aT
# Therefore the H(z) is (1 - e^-aT)*z / ( z - e^-aT )
FREQ_SAMPLING = 50e3
TIME_SAMPLING = 1 / FREQ_SAMPLING
FREQ_CUTOFF = 10 # Unit: Hz.
# The coefficient a is
a = 2 * pi * FREQ_CUTOFF * TIME_SAMPLING
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment