25

We know that in general transfer function of a filter is given by: $$H(z)=\dfrac{\sum_{k=0}^{M}b_kz^{-k}}{\sum_{k=0}^{N}a_kz^{-k}} $$ Now substitute $z=e^{j\omega}$ to evaluate the transfer function on the unit circle: $$H(e^{j\omega})=\dfrac{\sum_{k=0}^{M}b_ke^{-j\omega k}}{\sum_{k=0}^{N}a_ke^{-j\omega k}} $$ Thus this becomes only a problem of ...


14

this is just an addendum to jojek's answer which is more general and perfectly good when double-precision math is used. when there is less precision, there is a "cosine problem" that crops up when either the frequency in the frequency response is very low (much lower than Nyquist) and also when the resonant frequencies of the filter are very low. when you ...


14

You need to filter first and then downsample. Otherwise, you will run into aliasing problems. I.e. frequencies that are above 30 Hz will create images within your frequencies of interest. You can consider the little script below to compare both methods: Fs = 128.0 t = np.arange(0, 10, 1/Fs) signal = np.sin(2*np.pi*10*t) + np.sin(2*np.pi*50*t) sigma2 = 0.5 ...


8

The filter that you're referring to is called a preselection filter. Its purpose is to filter out everything but the desired signal of interest before mixing to baseband. Unwanted components could include other signals that are nearby in frequency, or just noise that lies outside the desired signal's bandwidth. Preselection can serve multiple purposes: It ...


8

The Butterworth filter's frequency response is the result of specific formulas and its characteristic is the flat passband frequency response. Consequently, if the coefficients of the IIR filter are modified in any way, the filter might not maintain the "Butterworth" characteristics. In addition to the responses by "Hilmar" and "Jason R", maybe you could ...


8

So the issue is that your filter order is too high. There are 2 problems with this: SciPy has a bug that generates inaccurate filters at high orders. On any platform, higher-order filters cannot be done in a single stage. SciPy bug: SciPy was previously generating prototype filters as a list of poles and zeros, then converting them to transfer functions, ...


7

In theory you can do this, but in practice it is difficult to do because the time and phase alignment must be pretty good for it to work. If the alignment is good you will get the destructive interference that you are seeking. If they aren't, you will get some constructive interference. Even worse, whether they are destructively or constructively ...


7

In the $s$-domain, the LPF-to-BPF transformation doubles the order of the filter. that is because the LPF has one transition from passband to stopband, but the BPF has two such transitions. Remember that when we do frequency response, we substitute $s=j\omega$. That is, we evaluate the $s$-plane transfer function $H(s)$ as $H(j\omega)$. The magnitude of $...


6

There is no magic bullet, I'm afraid. You can use an elliptic filter to independently control pass band ripple and stop band attenuation, however you will find that the decay rate is closely related to the steepness and overall bandwidth of the filter. You can make the filter decay drastically faster by reducing the filter order to 1, but then again the ...


6

Below the results as sos matrix and gain. Every row in the matrix is a single second order section in the coefficient order of b0, b1, b2, a0, a1, a2. Obviously we need a0=1, and the sections are normalized so that b0=1 as well. The overall gain accumulated is in the single number "gain". The fact that this gain is actually in the order of 10^-9 shows that ...


6

This is just "faking" the magnitude response of an IIR filter. The output's magnitude spectrum looks just like it has been filtered by the IIR filter with the given frequency response. Although it may somehow work, there are some limitations: Frequency-domain filtering is usually much more computationally demanding. It is not for real-time. The problem ...


5

The main issue with the example you gave is that the filter design function cheby1 is returning all NaNs, which isn't going to be a very good filter. The problem is how you're specifying the passband/stopband edge frequencies. This particular function is meant to emulate MATLAB's cheby1 function; the frequencies that you give it should be normalized, such ...


5

To calculating the overall gain of a Bainter stage, would I simply work out the individual gains of the three op-amp sections. The overall gain would then be the product of the three individual gains? The short answer is: Yes, you can (probably) analyze them individually. When asking what happens when you cascade multiple analog filter stages, the ...


5

This sort of filtering is done all the time, but it doesn't have the effect you think it should. Suppose you have an IIR filter with an impulse response of $h[n]$ which is represented in the $z$ domain as: $$ H\left(z^{-1}\right) = \frac{h_n\left(z^{-1}\right)}{h_d\left(z^{-1}\right)} $$ where $h_n$ is the numerator polynomial in $z^{-1}$ of order $N$ and $...


5

The denominator (recursive coefficients Ai) look OK: the poles of your system are at 45 degree angles ($\pi/4$), with magnitude 0.68 (which is not very aggressive for a notch filter; in my opinion they should be more like 0.9). But your numerator has its roots very near $z=1$, which corresponds to frequency 0 instead of the desired $\pi/4$ for implementing ...


5

So, first, to put things into perspective: 4kHz is not a high sampling rate these days (add 5 orders of magnitudes, and things become hard). Your 15 kHz passband doesn't say anything about the complexity of the filter; what counts is the transition width, ie. the distance between pass- and stopband, as well as the attenuation of the stopband. For a slightly ...


5

FIR coefficients are $h[n]$, the same as the impulse response. there are $N$ non-zero taps. $$ h[n] = 0 \qquad \text{for } n<0, n \ge N $$ frequency response is $$\begin{align} H(e^{j \omega}) &= \sum\limits_{n=-\infty}^{+\infty} h[n] e^{-j \omega n} \\ &= \sum\limits_{n=0}^{N-1} h[n] e^{-j \omega n} \\ &= \...


5

It must have to do with the initial conditions used by the function filtfilt.m. The idea is to match initial conditions in a way such that startup and end transients are minimized. This, however, doesn't always seem to work, and it appears that for your filter specifications it actually does more harm than good. As far as I know there is no way to tell ...


5

First of all, what is the order of your IIR filter? The highest order I have ever used was an order-10 IIR filter for a control loop application. I feel like it is unlikely that you need more that this. Second, it is a good idea to split your filter in second-order-sections (SOS) and cascade them , this usually fix most issues. https://www.dsprelated.com/...


4

Frequency domain filtering (FFT), as suggested by some comments, is definitely wrong -- it's even slower, or same speed at best! A recursive filter (IIR) is the fastes possible solution. If you choose a typical second order filter (called biquad in engineering slang) of Butterworth type and do your math right (factoring out coefficients) you only have 3 ...


4

The mixer/LPF filter that you describe as the receiver is typically one that is designed (possibly for optimal performance e.g. matched filter) using a mathematical model that assumes its input is the desired signal plus noise (often AWGN) and nothing else. If other signals are present, they are assumed to be orthogonal to the signal of interest (as in CDMA ...


4

As you stated there are some parameters associated with filters such as type of filter (butterworth, elliptic, chebyshev I,chebyshev II, bessel,...), order of filter, etc. (Note that there are lots of considerations in filter design bases on the application) Let's first talk about the order of filters: Filters with higher orders let you have a filter with ...


4

You can design the different filter types directly with the scipy.signal functions. There are three main functions for creating finite impulse response filters with the scipy.signal package. signal.remez signal.firwin signal.firwin2 The remez function, as arguments, takes the number of taps (order+1), the "bands", and the "desired" gain. The "bands" is ...


4

A filter bank is a collection of bandpass filters designed to split a signal into a number of bands. The centre frequencies of the band pass filters can be spaced linearly or according to a non-linear spacing depending on the intended application. $H(z)$ denotes the $z$-domain transfer function of a filter in the bank.


4

The filter you designed is a linear phase filter, therefore, response of the filter will start at $N/2$th sample, where $N $ is the filter order. As $N$ increases so does the delay of the response. You can find this delay value by computing group delay of the filter. In case you want to reduce the delay, you can design a minimum phase filter.


4

Basically you never want to use the Transfer Function representation (with b and a) and rather use the Zeros-Poles-Gain (z,p,k). This will allow you to avoid the numerical errors. In your case you might design your filter in following way: fs = 44100; % Sampling frequency Wp = [30, 70]/(fs/2); % Pass band frequencies (as normalized frequency) Ws = ...


4

You just shifted the low pass filter to the right, so you generated a complex-valued filter, as you've observed. Multiplying a real-valued impulse response with a complex exponential naturally results in a complex-valued impulse response. What you actually have to do is shift the spectrum to the right and to the left: $$h_{BP}[n]=h_{LP}[n]e^{jn\omega_0}+h_{...


4

Since I can't comment on this particular site I'd say this, consider the following before you do what you're trying to do. Due to the Nyquist law you want your sampling frequency to be that of the DOUBLE of the maximum frequency your analog signal has. If you downsample to 64 hz that means you'll only be able to see signal data up to 32 Hz. EEG contains the ...


4

As the frequency bands are simple frequency ranges, I wonder if I can use several bandpass filters to get them (instead of using WPT / FFT)? Sure! That's how it's usually done! Is there any reason not to do it (performance)? diabolical laugther as it happens, I've prepared just the blog post for you… TL;DR: If you don't have to process more than 20 ...


4

The generalized linear phase FIR filter has the following frequency response: $$H(\omega) = A(\omega)~e^{j (\alpha \omega + \beta)}$$ for some constant $\alpha$ and $\beta$ and $A(\omega)$ being real. The group delay of this filter is independent of frequency: $$\tau = -\frac{d (\alpha \omega + \beta) } {d \omega} = - \alpha $$ Now if you linearly shift ...


Only top voted, non community-wiki answers of a minimum length are eligible