Hot answers tagged

5

Computing your DFT with a 0.5 Hz spacing is equivalent to appending your signal with 1000 zeros and then computing a 2000 point DFT. It should be clear that this adds no real information to the signal. Yet it can sometimes be useful. What really happens by this zero padding is that you're seeing an interpolated version of your spectrum. This means that ...


5

Note that when you compute the DFT, you compute the dot product with a sine term and with a cosine term. In your third example, even though the dot product with the sine term is zero, the dot product with the cosine term isn't, so you do get spectral leakage, as you expected. The dot product with the sine term is zero because you have a whole number of ...


4

Relating the DFT to the FT (CTFT) is a big issue. Let's start with the basic definitions without any domain specification using a $\frac{1}{N}$ normalization on the DFT. $$ FT(x(t))(f) = \int x(t) e^{-i2\pi t f } dt $$ $$ DFT(x[n])(k) = \frac{1}{N} \sum x[n] e^{-i 2\pi \frac{n}{N} k } $$ They are obviously similar. Assuming they cover the same interval, ...


4

The answer above is correct. Just to clarify a bit further, using x = np.linspace(0,10,5) will produce 5 numbers from 0 to 10 inclusively np.linspace(0,10,5) array([ 0. , 2.5, 5. , 7.5, 10. ]) You don't want the last number because in your example the last number is the first number of the next period. A correct implementation would be: periods = 4.*np....


3

Dot returns zero, but I don't understand why. Why do we get zero here instead of a non-zero number Luck mostly. It's only zero because you chose the right phase difference. If you add any non-trivial phase to either one of the sine waves, you would get a non zero result. That's NOT the case for 5Hz and 6 Hz, where the dot product is zero regardless of the ...


3

There is a very important point that is being glossed over in this question (which follows how this topic is conventinally taught) which is: The DFT does not care what your sampling rate is. Ultimately, every DFT calculation boils down to these parameters using conventional naming: $$ \begin{aligned} N &= SamplesPerFrame = \frac{Samples}{Frame}\\ k &...


2

@Henrique Luna. Please forgive me. In Part (b) of the problem the words "sequence time" should "time sequence". Sorry for the confusion! Years ago when I created that Part (b) question I was thinking about the answer to the question; "What is the time duration of an N-sample time-domain sequence?" Back then I believed the time ...


2

For a single pure tone across the frame, the frequencies below 1 cycle per frame (the DFT doesn't care about the sampling rate) represent fractions of a single cycle across the frame. Theoretically, they can be measured just as accurately as a tone with with more cycles across the frame. As long as there is just a single pure tone, the frequency (then the ...


2

There are two factors involved here. One has been mentioned in a comment: your truncation error is larger for smaller values of $N$ because you truncate the time domain function at $NT$, where the sampling interval $T$ is constant. The other factor - which is the more important one here - is that you divide the FFT result by $N$. That's why you see a ...


2

Taking the inverse FFT (IFFT) instead of FFT would cause a phase inversion.


2

If you want to learn about the DFT standalone you need to ditch the Hz. DFT exercise in the book Understanding digital signal processing 3 Ed Any two Sine or Cosine waves multiplied together are the same as the sum or the difference of two others. It's just a matter of getting the phases line up. $$ \cos(X)\cos(Y) = \frac{1}{2} \left( \cos(X+Y) + \cos(X-Y) \...


2

You can't do better than this for accuracy in my experience. A Two Bin Solution Select a frame size of 1 1/2 cycles or 2 1/2 cycles. You only need to calculate two bins, either 1 and 2, or 2 and 3. No need for a full DFT. So it is very efficient as well. By placing the frequency squarely near the center of the two bins you minimize noise effects and ...


2

The FFT is faster than the naive DFT through matrix-vector products because it can reuse many intermediate results. However, for inputs this sparse, there's really not much that can be re-used, even in the best case. So, the most efficient way here is probably to work straight forward: Allocate the space ($N=7408800$ values) for your output (initialize with ...


1

As promised, here is a little derivation to give some insight into the effects of windows on DFT values done in reverse. Suppose that I have a DFT from some signal. \begin{equation} \begin{aligned} X[k] &= \sum\limits_{n=0}^{N-1} x[n] e^{-i\frac{2\pi}{N}kn} \end{aligned} \end{equation} I look at it, decide it needs a little "smoothing", so I ...


1

Hints only: Think about time-frequency duality of DFT pairs. What is the DFT of sequence $-1^k$? And then there is a phase term in the DFT, so there should be a shift in discrete time sequence. Use time-delay property of DFT. These 2 properties should give you the solution.


1

Supplement on the nature of your source data While testing my pll software simulator, I ran it on the voltage/current datasets of your github reference and noticed an unusual behavior of the phase detector output (phase error). Intrigued, I've computed fft of your dataset voltages/currents. The voltage's FFT is quite smooth, phase noise at the end of the ...


1

A couple of things I’ve noticed, the combination of which likely is at the root of the issue. First, when you apply a window, you are applying a linear phase shift to the frequency transform. You could subtract it out, and it would probably fix the issue. This wouldn’t necessarily be a problem except... Second, your code calculates the max values for the ...


1

Your problem is here: x = np.linspace(0.,4.*np.pi,n) The period should be N+1 samples from 0 to 2pi, for n=0..N. Then take x(k) for k=0..N-1 Currently your FFT is not a pure single tone, because the sinusoid does not have a perfect period within the FFT period. And so padding with zeros would not be the correct padding. The fix above will a perfect ...


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