I made my own low pass filter in matlab by taking a moving average of the signal data. But if a moving average creates a low pass filter, how exactly does one design an equation for a high pass filter? I understand the intuition regarding using an average for low pass (high frequencies will average out to zero but low frequencies will average out to a number close to the signal value).
But is there any equation used for high pass filter?
Using a stereo system as a practical example, a capacitor connected in series with the tweeter (treble) speaker will serve as a high-pass filter, imposing a high impedance to low-frequency bass signals, thereby preventing that power from being wasted on a speaker inefficient for reproducing such sounds.
The “Q” or Quality Factor In a Band Pass Filter circuit, the overall width of the actual pass band between the upper and lower -3dB corner points of the filter determines the Quality Factor or Q-point of the circuit.
The cut-off frequency or -3dB point, can be found using the standard formula, ƒc = 1/(2πRC). The phase angle of the output signal at ƒc and is -45o for a Low Pass Filter.
There are a lot of equations for that! Perhaps the simplest one is the one-sample delay difference function,
y[n] = x[n] - x[n-1]
or, taking its Z-transform
H(z) = 1 - z^-1
Where H(z) = Y(z) / X(z)
is the system equation for the filter.
Using AudioLazy with MatPlotLib (Python), you can see a frequency response plot for this highpass filter by typing. (Disclosure: I am the author of AudioLazy)
from audiolazy import z
(1 - z ** -1).plot().show()
You can apply it to a signal, as well
from audiolazy import z, Stream
filt = 1 - z ** -1
sig = Stream(1, 3, 1, -1, -3, -1) # Periodic signal
filt(sig).take(7)
Resulting in the first 7 samples:
[1.0, 2, -2, -2, -2, 2, 2]
The same can be done in GNU Octave (or MatLab):
filter([1, -1], [1], [1, 3, 1, -1, -3, -1, 1])
Which returns
[1, 2, -2, -2, -2, 2, 2]
That's a FIR filter in a 6-sample-periodic signal that decays from [-3;3]
amplitude range to [-2;2]
range in this example. If you try with a 12-sample-signal (lower frequency):
filt = 1 - z ** -1
sig = Stream(1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, 0)
filt(sig).take(13)
Now the result is another square wave, but in the [-1;1]
range. You should try the same with sinusoids, which are meaningful for the frequency response and should keep another sinusoid as the output of the filter, with the same frequency.
You can also use a resonator at the Nyquist frequency, giving you an IIR filter. There are several other filters design that can do so (e.g. Butterworth, Chebyshev, Elliptical), for different needs. Minimum phase, linear phase, filter stability and minimizing the ripple amplitude are some possible design goals (or constraints) you can have while designing a filter.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With