High resolution FFT from time domain data.
4 views (last 30 days)
Show older comments
I have a very large time domain data with a lot of samples, but still I am not getting a good resolution in the FFT spectrum. Is that because I have to change the value of Fs (in the code below)? I have also attached the data file, code and the plot.
I get all the points in the FFT spectrum spaced with 50 Hz spacing. But I need a god resolution. Because the resolution is not good, hence the information and other linked parts of my code are not functioning correctly.
Please let me know what can be done about this. Thanks in advance.
Code:
fft_columns = [];
for i = 2:1:size(data,2)
X = data;
xdft = fft(X(:,i));
DT = X(2,1)-X(1,1);
% sampling frequency
Fs = 1/DT;
DF = Fs/size(X,1);
freq = 0:DF:Fs/2;
N = length(X);
xdft = xdft(1:length(xdft)/2+1)';
Xmag = abs(xdft); % Spectral magnitude
Xdb = 20*log10(Xmag);
Xdb(1,1) = Xdb(1,2);
XdbMax = max(Xdb); % Peak dB magnitude
Xdbn = Xdb - XdbMax;
%Xdbn = Xdb - 0;
dBmin = -120; % Don't show anything lower than this
Xdbp = max(Xdbn,dBmin); % Normalized, clipped, dB mag spec
fft_columns = [fft_columns; Xdbp];
end
%dB = mag2db(abs(xdft))
% psdx = (1/(Fs*N)) * abs(xdft).^2;
% psdx(2:end-1) = 2*psdx(2:end-1);
%%
figure('Position', [1 1 4000 700])
%figure
plot(freq,fft_columns(1,:),'color', [1,0.55,0],'LineWidth',7);
axis([0 5000 -79 2])
Plot:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/466040/image.jpeg)
0 Comments
Answers (1)
See Also
Categories
Find more on Parametric Spectral Estimation 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!