Need to Decrease the Width of FFT

8 views (last 30 days)
Chirag
Chirag on 30 Jun 2011
Hi
I'm quite new to MATLAB. I'm working on spectral analysis of a signal and trying to obtain its FFT. But the problem is that my spectral lines are coming out to be quite braod and eventually, data analysis is not possible. I'm using the following code for the obtaining the FFT:
M = 2.5e-4; Fs = 1/M; T = 1/Fs; L=1000000; NFFT = 2^nextpow2(L); Y = fft(ias, NFFT)/L; f = Fs/2*linspace(0,1,NFFT/2+1); plot(f,2*abs(Y(1:NFFT/2+1)))
Kindly suggest some solution for this problem.
Thanks and Regards.

Answers (3)

Rick Rosson
Rick Rosson on 1 Jul 2011
Please try the following code. To increase the resolution of the Fourier spectrum, increase the value of the parameter k (and vice versa):
% Up-Sampling factor:
k = 4;
[M,N] = size(ias);
% Zero pad the signal:
ias = [ias ; zeros((k-1)*M,N) ];
M = k*M;
% Time domain:
dt = 2.5e-4;
t = dt*(0:M-1)';
% Frequency domain:
Fs = 1/dt;
dF = Fs/M;
f = (-Fs/2:dF:Fs/2-dF)';
% Discrete Fourier Transform:
Y = fftshift(fft(ias))/M;
% Plot the spectrum:
figure;
plot(f,abs(Y));
HTH.
  2 Comments
Chirag
Chirag on 1 Jul 2011
Thanks a lot for the answer.
I tried the code. But it didn't work. There is no change in the width. I varied the value of M from 4 to 4000.
I think the problem is with the data points. Is there anyway I can increase the number of data points in my code. For the sake of simplicity, I'm taking the FFT of a sin wave with freq of 50 HZ, but the spectral line is from 48.5 to 51.5 Hz. It might be due to less number of data points being fed to FFT function.
Thanks a lot again.
Chirag
Chirag on 1 Jul 2011
I think if i'm able to increase the data points, problem will be solved. Please let me know if there is any way to do so.
Thanks.

Sign in to comment.


Christos Saragiotis
Christos Saragiotis on 2 Jul 2011
Dear Chirag,
From what you say, I understand that you want to decrease the df of your spectrum. You know that df = 1/(N dt), where N is the number of your samples and dt = 1/fs is the sampling interval. Therefore, df = 1/T where T = N dt is the total time of observation.
So in order to make df finer, you need to increase the time of recording, T.
When you just zero-pad (as when you take the 2^nextpow2), your figure will have a finer df but in fact the resolution hasn't increased. fft just "interpolates" the values.
Regards,
Christos
  2 Comments
Rick Rosson
Rick Rosson on 2 Jul 2011
Yes, that is correct.
Chirag
Chirag on 4 Jul 2011
Thank you for your reply. I tried the method you suggested, but unfortunately it didn't work.
Kindly, go through the link to have a better look at my problem:
https://docs.google.com/leaf?id=0B4dPcFFHHl9VZGM3ZmJiMWItYzAyMy00YjAxLWFhOWUtYTA3YjRiNTI3ODE4&hl=en_US
Thanks and regards.

Sign in to comment.


Rick Rosson
Rick Rosson on 1 Jul 2011
Hi Chirag,
If you know that the input signal is a pure-tone sine wave at 50 Hz, then you can simply generate the signal to any length that you want. The more samples you add to the sine wave, the narrower will be the resulting spectral line.
Please try the following:
% Up-Sampling factor:
k = 4;
[M,N] = size(ias);
M = k*M;
% Time domain:
dt = 2.5e-4;
t = dt*(0:M-1)';
% Generate pure tone sine wave:
A = 1;
Fc = 50;
ias = A*cos(2*pi*Fc*t);
% Frequency domain:
Fs = 1/dt;
dF = Fs/M;
f = (-Fs/2:dF:Fs/2-dF)';
% Discrete Fourier Transform:
Y = fftshift(fft(ias))/M;
% Plot the spectrum:
figure;
plot(f,abs(Y));
HTH.
Rick
  1 Comment
Chirag
Chirag on 4 Jul 2011
Thank you for your reply. I tried the method you suggested, but unfortunately it didn't work.
Kindly, go through the link to have a better look at my problem:
https://docs.google.com/leaf?id=0B4dPcFFHHl9VZGM3ZmJiMWItYzAyMy00YjAxLWFhOWUtYTA3YjRiNTI3ODE4&hl=en_US
Thanks and regards.

Sign in to comment.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!