Need to Decrease the Width of FFT
5 views (last 30 days)
Show older comments
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.
0 Comments
Answers (3)
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.
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
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
See Also
Categories
Find more on Fourier Analysis and Filtering in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!