New answers tagged

2

The following is useful in applications where we want to null out interfering tones that are within are spectrum of interest where our signal occupies, so with that we want to minimize how much spectrum we remove. In cases where we are really only interested in the signal at 60 Hz (as the OP may be) then a PLL or 2nd order resonator would be most applicable ...


0

My apologies if this is more of a comment then an answer, given my low reputation. As the other comments have mentioned, a sinusoidal impulse response at 60 Hz would be adequate for satisfying the removal of harmonics. If you are concerned with preserving group-delay (and thus phase-delay), consider using a zero-phase digital filter. The MATLAB documentation ...


4

Like @MattL. and @aconcernedcitizen say, the issue is numerical. Python's scipy.signal.firls uses internally the solver scipy.linalg.solve. For your input, the solver throws a "matrix singular" error, but firls suppresses the error and falls back to another solver scipy.linalg.lstsq which doesn't throw an error but also doesn't get the problem ...


6

The problem lies in the formulation of the desired response, and especially in the "don't care" region, which is extremely wide for the chosen filter length. Even though I can't give any exact relation between transition band width and filter length, I know that in the case of a least squares design, the matrix of the system of linear equations ...


1

To align the samples (and realigning with different filter implementations) consider implementing actual timing and carrier recovery loops, or using those discriminators and approaches to manually correcting the offsets as would be done in those acquisition and tracking loops. This will put you on the road toward an actual implementation when the transmitter ...


0

A simple solution to model fixed point IIR filters in Python is to use integer and modulo arithmetic. There are also fixed point libraries out there for more extensive implementations that would be useful for bit accurate modelling and verification but for simple testing of quantization effects on IIR and FIR filters using integer math should be more than ...


2

To help your intuition, consider a sinusoidal signal with frequency $\omega_0$ and some arbitrary but constant phase $\phi$: $$x[n]=A\sin(\omega_0n+\phi)\tag{1}$$ Delaying the signal $x[n]$ by $n_0$ samples gives $$\begin{align}x[n-n_0]&=A\sin\big(\omega_0(n-n_0)+\phi\big)\\&=A\sin\big(\omega_0n-\omega_0n_0+\phi\big)\\&=A\sin\big(\omega_0n+\...


-1

One can show this mathematically by factoring and using Euler's formula \begin{align} H(\exp(j\omega T)) &= 1 + \exp(-j\omega T) \\ &= (\exp(j\omega T/2) + \exp(-j\omega T/2)) \exp(-j\omega T/2) \\ &= (\cos(\omega T/2) + j\sin(\omega T/2) + \cos(\omega T/2) - j\sin(\omega T/2)) \exp(-j\omega T/2) \\ &= 2 \cos(\omega T/2) \exp(-j\omega T/2) \...


3

My code is wrong Even without assuming that the code's behavior is wrong, for long-term maintainability it has its problems. You'd do much better to structure your code such that you have a data type defined that describes a 2nd-order filter (in C or C++ it would be a struct or class), and a data type that describes a filter's state (in C or C++ it could be ...


3

c) My code is wrong That one. You have your difference equations backwards. It should be $$y[n] = x[n] + 2x[n-1] + x[n-2] - a_1y[n-1] - a_2y[n-2]$$ You have your "a" and "b" coefficient swapped. You can probably do it this way, but it feels needlessly complicated. IMO it's easier to Start with the poles of an analog prototype filter. ...


Top 50 recent answers are included