DSPRelated.com
Forums

FFT Matlab - What is a N-point FFT?

Started by Unknown April 15, 2006
I have been collecting emg signal and would like to look at the
frequency of the signal.  In Matlab I know there is an FFT function
which I have been using, but ran into a problem when using it.  The
example given in the help says it is using a 512-point FFT.  I tried
using a 512-point FFT and a 2056-point FFT and noticed that they look
very different.  Is the only difference that the 512 gives less points
to plot than the 2056?

I noticed when I plotted signal of a specific length (1:1000) then
plotted more of the same signal (1:2000), the frequency spectrum
overlapped completely if I used the 512, but if I used the 2056 there
was change (plots did not completely overlap) in frequency
distribution.  The latter is what I would expect to see, but was
wondering why this would occur?

Thank you very much.

>I have been collecting emg signal and would like to look at the >frequency of the signal. In Matlab I know there is an FFT function >which I have been using, but ran into a problem when using it. The >example given in the help says it is using a 512-point FFT. I tried >using a 512-point FFT and a 2056-point FFT and noticed that they look >very different. Is the only difference that the 512 gives less points >to plot than the 2056? > >I noticed when I plotted signal of a specific length (1:1000) then >plotted more of the same signal (1:2000), the frequency spectrum >overlapped completely if I used the 512, but if I used the 2056 there >was change (plots did not completely overlap) in frequency >distribution. The latter is what I would expect to see, but was >wondering why this would occur? > >Thank you very much. >
If you are going to perform a N-point FFT in MATLAB, to get an appropriate answer, the length of your sequence should be lesser than or equal to N. Usually this N is chosen in power of 2, because MATLAB employs a Radix-2 FFT if it is, and a slower algorithm if it is not. So, if you give a sequence of length 1000 for a 2056 point FFT, MATLAB will pad 1056 zeros after your signal and compute the FFT. Similarly, if your sequence length is 2000, it will pad 56 zeros and perform a 2056 point FFT. But if you try to compute a 512-point FFT over a sequence of length 1000, MATLAB will take only the first 512 points and truncate the rest. If you try to compare between a 1024 point FFT and a 2056-point FFT over a [1:1000], you will get a similar plot. So the moral: choose your N to be greater than or equal to the length of the sequence. - Krishna
Thank you very much for the response.  I did try this, and noticed that
the magnitude of the signal is small if you were to use a larger (2056)
points.  However if only the Y value is plotted the curves would match.
 However, when it is plotted on the frequency spectrum the larger has
smaller magnitudes...is this normal?

jpopovich@gmail.com skrev:
> Thank you very much for the response. I did try this, and noticed that > the magnitude of the signal is small if you were to use a larger (2056) > points. However if only the Y value is plotted the curves would match. > However, when it is plotted on the frequency spectrum the larger has > smaller magnitudes...is this normal?
These are more or less as expected. Explaining why takes just a little too much time and effort for USENET, though. If you are about to use the spectra for any particular purpose, I would suggest you get an intro text on DSP. One text that often is suggested here is Lyons: Understanding Digital Signal Processing, 2nd ed., Prentice Hall, 2004. Understanding the properties of the DFT (the procedure that take the data as input and produce spectra as output) is at the core of DSP. It is a subject worth spending time on. Lyons is very good at explaining these things, he assumes no prior knowledge of DSP. If and when you have further questions after reading his book, just ask a question here and you will get lots of help. Rune
>Thank you very much for the response. I did try this, and noticed that >the magnitude of the signal is small if you were to use a larger (2056) >points. However if only the Y value is plotted the curves would match.
What do you mean by "Y value"?
> However, when it is plotted on the frequency spectrum the larger has >smaller magnitudes...is this normal? >
I do not think it is normal. Whenever you are trying to plot the frequency spectra, plot the absolute and the argument seperately. I think the problem is the way in which you observe the comparison. Consider a signal in the range [1:1024]. When you compare the 1024-pt FFT of this signal with its 2056-point FFT, you can observe that the 2056-point FFT interpolates the values between two particles of your 1024-point FFT. That is the (n)th sample of the 1024-FFT output would match with the (2n - 1)th sample of the 2056-point FFT, for a one based indexing. And every (2n)th component would be the result of interpolation. Now try plotting the 1024-point FFT output and the odd-numbered (for one based indexing)samples of 2056-point FFT. You would see that these two match in magnitude and phase. - Krishna
krishna_sun82 wrote:
>>Thank you very much for the response. I did try this, and noticed that >>the magnitude of the signal is small if you were to use a larger (2056) >>points. However if only the Y value is plotted the curves would match. > > > What do you mean by "Y value"? > > >>However, when it is plotted on the frequency spectrum the larger has >>smaller magnitudes...is this normal? >> > > > I do not think it is normal.
Scaling is a perfectly normal property of FFT's. For more information, just ask Mr. Google. -- GCP
Thank you for the reference.  My problem is, I have a very limited
background in math (only take up to introductory calculus), and often
times have problems interpreting the DSP literature.  I will take a
loot at Lyons.  Thanks again!

Thank you for the response!

What do you mean by "Y value"?

For example:

x=data(1:1024);
y = fft(x, 1024);
y2 = fft(x, 2056);
y_mag = y.*conj(y) / 1024;
y2_mag = y2.*conj(y2) / 2056;

What I observed is that when each are plotted seperately, the shape is
similar but the Y-axis values difffer.
That is, the y2_mag value (2056-point fft) is smaller than the values
for the y_mag (1024-point fft).

>Consider a signal in the range [1:1024]. When you compare the 1024-pt FFT >of this signal with its 2056-point FFT, you can observe that the >2056-point FFT interpolates the values between two particles of your >1024-point FFT. That is the (n)th sample of the 1024-FFT output would >match with the (2n - 1)th sample of the 2056-point FFT, for a one based >indexing. And every (2n)th component would be the result of >interpolation.
>Now try plotting the 1024-point FFT output and the odd-numbered (for one >based indexing)samples of 2056-point FFT. You would see that these two >match in magnitude and phase.
I tried this and noticed that they match again in shape and phase, but the absolute magnitudes differ:
>From above,
y_mag = y.*conj(y) / 1024; y2_mag = y2.*conj(y2) / 2056; plot(y_mag); hold on plot(y2_mag(1:2:2056,1), 'r')% Plotting the odd numbers I noticed that the y2_mag (odd values) are still smaller than that of the y_mag values. Is this correct or am I doing something wrong? Thank you so much for your help!
> >plot(y_mag); >hold on >plot(y2_mag(1:2:2056,1), 'r')% Plotting the odd numbers > >I noticed that the y2_mag (odd values) are still smaller than that of >the y_mag values. > >Is this correct or am I doing something wrong? Thank you so much for >your help! >
This is correct. You are not doing anything wrong and nor does MATLAB. You can get an explanation for why it is correct in any standard book on Maths or signal processing. - Krishna
Thank you very much!  This has been very helpful!