# Tag Info

23

The fact that the result is complex is to be expected. I want to point out a couple things: You are applying a brick-wall frequency-domain filter to the data, attempting to zero out all FFT outputs that correspond to a frequency greater than 0.005 Hz, then inverse-transforming to get a time-domain signal again. In order for the result to be real, then the ...

19

The frequency response for the filter designed using the butter function is: But there is no reason to limit the filter to a constant monotonic filter design. If you desire a higher attenuation in the stopband and steeper transition band, other options exist. For more information on specifying a filter using iirdesing see this. As shown by the frequency ...

16

What you have here is the equivalent of a moving-average filter. Specifically, it is a filter of order 1, whose impuse response is $$h(n)=\delta(n)+\delta(n-1)$$ Taking its $Z$-transform, we get $$H(z)=1+z^{-1}=\frac{z+1}{z}$$ There is a pole at $z=0$ and a zero at $z=-1$. Plotting the magnitude of the frequency response $H(\omega)\triangleq H(e^{-\... 13 For digital notch filters, I like to use the following form for a notch filter at DC ($ \omega $=0): $$H(z) = \frac{1+a}{2}\frac{(z-1)}{(z-a)}$$ where$a$is a real positive number < 1. The closer$a$is to 1, the tighter the notch (and the more digital precision needed to implement). This is of the form with a zero = 1, and a pole =$a$, where$a$... 12 FFT -> zeroing coefficients -> IFFT is not the correct way of doing filtering - the actual filter realized by doing so has poor characteristics. The correct way of filtering signals is to compute the coefficients of a digital filter, a process known as filter design and for which a large body of software tools/documentation is available, and apply it to ... 11 You asked how a low pass filter works and mentioned that the filter uses past values of you're data. This is a non-technical discussion of what happens in a low pass filter. The low pass filter takes differing views (shifted in time) of your signal, scales them and adds them together. You can imagine drawing your signal 3 times, one being current, the ... 11 If you only have a finite number of samples and are using a finite length FFT, then you will end up with a finite number of FFT frequency result bins. Each bin has a one-to-one relationship ONLY with frequencies that are exactly integer periodic in the FFT length. Any other spectrum frequencies that are not exactly periodic in the FFT aperture will not ... 11 To be able to analyze what a low pass filter does first you would need to understand what a Fourier transform is, hence some theory first. The Fourier transform essentially represents the time-domain information stored in some function (a square wave in your case) in terms of frequencies. A simple example would be a sine wave$sin(2\pi f_{c} t)$which ... 10 Both low pass filtering and polynomial regression smoothing could be seen as approximations of a function. However, the means of doing this are different. The key question to ask here is "Can you do one in terms of the other?" and the short answer is "not always", for reasons that are explained below. When smoothing by filtering the key operation is ... 10 In reviewing fred harris Figures of Merit for various windows (Table 1 in this link) the Hamming is compared to the Hanning (Hann) at various values of$\alpha$and from that it is clear that the Hanning would provide greater stopband rejection (The classic Hann is with$\alpha =2$and from the table the side-lobe fall-off is -18 dB per octave). I provided ... 9 This answer provides a quick introduction to decimation concepts and CIC filters which I would consider as one solution given the description. Bottom Line First Given your use of a microcontroller, (implied emphasis on minimizing resources), and that you indicated you do not need a high performance filter- consider doing everything with Cascade-Integrator-... 9 I'm new, so I can't add this comment to Matt L.'s answer. It is not an exponential filter, the equation is actually: $$y[n] \ = \ \alpha \, x[n] \ + \ ( 1 - \alpha ) \, x[n-1]$$ So it is a very short FIR filter, not an IIR filter. I'm not expert enough to know a specific name. Ced ============================================= Followup: I want to ... 8 The best way to apply frequency domain filtering for signal streams is overlap add (or related flavors overlap save, or block convolvers, etc.). You basically take in one frame at a time (say 1024 samples). Zero pad to twice the length (2048), do an FFT, multiply with (also zero padded) transfer function of the filter, do an inverse FFT. Save the last 1024 ... 8 You need a filter whose transfer function evaluated at 0 (DC component) is 1, or equivalently, whose impulse response sums to 1. 8 Two exact sine waves of the same frequency but different phases sum to another exact sine wave. That resultant sine wave can be decomposed into an infinite numbers of pairs (or any other greater number) of sine waves of the same frequency, not just the two original ones. Thus more information is required to reduce the possible solution space below infinite.... 8$E_1=E_{10}sin (\omega t)E_2=E_{20}sin (\omega t + \delta)E_{\theta} = E_1 + E_2 = E_{\theta0}sin (\omega t + \phi )$This can be described as the figure below: Now given the$E_{\theta 0}$, you can rotate$E_1$and$E_2$arbitrarily as long as$E_1$,$E_2$, and$E_{\theta 0}$form the triangular. As a result, your given sine wave can be ... 8 The result will indeed be a high pass filter. From your difference equation, the transfer function of the low pass filter is $$H_l(z)=\frac{\beta}{1-(1-\beta)z^{-1}}\tag{1}$$ with$\beta=1/\alpha$. Note that this is actually a leaky integrator, not a classic low pass filter, because its frequency response does not have a zero at Nyquist. The high pass ... 8 In general you can't simply subtract a low-pass filtered version of a signal from the original one to obtain a high-pass filtered signal. The reason is as follows. What you're actually doing is implement a system with frequency response $$H(\omega)=1-H_{LP}(\omega)\tag{1}$$ where$H_{LP}(\omega)$is the frequency response of the low-pass filter. Note that$...

8

Yes. This looks like it's a typical first order low pass. The time constant can be determined by looking at the time it takes for the falling edge to drop to 37% of the max amplitude ($e^{-1}$). The cutoff frequency of the low pass filter is $1/(2 \cdot \pi \cdot t_c)$ where $t_c$ is the time constant

8

I don't get your downsample step when you downsampled by factor $M$. Let me go from scratch with the spectrum visualization below, with time domain, continuous frequency domain and discrete frequency domain from left to right. When we reduce the sampling frequency by a factor $k$, the signal spectrum is copied to new replicas at $f_s/k$. The discrete ...

7

Convolution in linear time-invariant system is asociative. So to get the equivalent mask you just need to convolve the kernel with itself twice. This will then then give you a 7x7 kernel: octave:1> a = [ 1 1 1 ; 1 1 1 ; 1 1 1 ] a = 1 1 1 1 1 1 1 1 1 octave:2> conv2(a,conv2(a,a)) ans = 1 3 6 7 6 3 1 3 ...

7

There are three potential problems with what you are doing: Zeroing out the high frequencies causes ringing due to the Gibbs phenomenon. You are essentially multiplying the Fourier transform with a square function, which is equivalent to circularly convolving the time-domain data with the inverse transform of the square function, which is a sinc function. ...

7

Is removing values from FFT result same as filtering? Yes, as one would expect intuitively. Taking the FFT of a signal will give you a frequency domain interpretation of the signal, if you then modify the magnitude of frequency bins and take the inverse FFT you will have a signal which is 'filtered'. Why is this not an 'ideal' (low pass) filter? Consider ...

7

Typically the advantages of an FIR filter are that it is easy to obtain a linear phase response, and numerical stability is not normally a problem. An IIR filter typically requires fewer taps (as you have observed), so is more efficient computationally, but the phase response tends to be somewhat erratic, and numerical stability is more likely to be an ...

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 $... 7 The Kalman filter is the optimal filter under various assumptions. You need to check whether those assumptions hold in your case: a) the model perfectly matches the real system, b) the entering noise is white and Gaussian and c) the covariances of the noise are exactly known. Without further detail I can't say whether your statement My ... 7 You should not be using the analog filter - use a digital filter instead. You want the filter to be defined in Z-domain, not S-domain. Also, you should define the time vector with known sampling frequency to avoid any confusion. The design of the digital filter requires cut-off frequency to be normalized by fs/2. Here is a working example: import numpy as ... 7 The given single-pole IIR filter is also called exponentially weighted moving average (EWMA) filter, and it is defined by the following difference equation: $$y[n]=\alpha x[n]+(1-\alpha)y[n-1],\qquad 0<\alpha<1\tag{1}$$ Its transfer function is $$H(z)=\frac{\alpha}{1-(1-\alpha)z^{-1}}\tag{2}$$ The exact formula for the required value of$\alpha$... 6 The frequency response of the two complementary filters are$H_2(e^{j\theta}) = 1 - H_1(e^{j\theta})$, or the impulse responses$h_2[n] = \delta[n] - h_1[n]$. For an IIR filter,$H_1(z)$can be written as$\frac{b_0 + b_1 z^{-1} + \ldots}{a_0 + a_1 z^{-1} + \ldots}$. Then$H_2(z)$should be something like$\frac{(a_0 - b_0) + (a_1 - b_1) z^{-1} + \ldots}{...

6

Yes of course, you can apply the filter directly to the integer samples, using fixed point arithmetic. For example, if you use a FIR filter with coefficients [1 / 3, 1, 1 / 2], and an 8-bit resolution for coefficients, your output will be: out[n] = (85 * sample[n] + 256 * sample[n - 1] + 128 * sample[n - 2]) >> 8 Two things to take be careful about: ...

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