FFT of a damping signal

27 views (last 30 days)
DebiPrasad
DebiPrasad on 1 Aug 2017
Commented: Star Strider on 1 Nov 2017
Hello, I have got a damping time dependent signal(attached data) and I wish to get the FFT of the signal. Unfortunately right now I am not able to get the peak frequency. Can someone help me in finding the FFT please.
  2 Comments
dpb
dpb on 1 Aug 2017
What have you tried?
DebiPrasad
DebiPrasad on 1 Aug 2017
if true
% code
end
f = (1./tvec);
nfft=length(y);
nfft2=2^nextpow2(nfft);
ff=fft(y,nfft2);
Mx_fft=ff(1:nfft2/2);
xfft=(length(f))*(0:nfft2/2-1)/nfft2;
%fff=ff(1:nfft2/2);
%Mxfft=(1./tvec)'*(0:nfft2/2-1)/nfft2;
figure(4)
plot(xfft,abs(Mx_fft))
f = (1./tvec);
nfft=length(Mx);
nfft2=2^nextpow2(nfft);
ff=fft(Mx,nfft2); Mx_fft=ff(1:nfft2/2); xfft=(length(f))*(0:nfft2/2-1)/nfft2; %fff=ff(1:nfft2/2); %Mxfft=(1./tvec)'*(0:nfft2/2-1)/nfft2; figure(4) plot(xfft,abs(Mx_fft))

Sign in to comment.

Accepted Answer

Star Strider
Star Strider on 1 Aug 2017
Try this:
D = load('FFT.txt');
t = D(:,1);
s = D(:,2);
Ts = mean(diff(t)); % Sampling Time
Fs = 1/Ts; % Sampling Frequency
Fn = Fs/2; % Nyquist Frequency
L = length(t);
FTs = fft(s)/L;
Fv = linspace(0, 1, fix(L/2)+1)*Fn; % Frequency Vector
Iv = 1:length(Fv); % Index Vector
[pks,locs] = findpeaks(abs(FTs(Iv))*2, 'MinPeakHeight',1E-3);
figure(1)
loglog(Fv, abs(FTs(Iv))*2)
hold on
plot(Fv(locs), pks, '^r')
grid
text(Fv(locs)*1.1, pks, sprintf('\\leftarrow Peak = %.5f at %.3E Hz', pks, Fv(locs)), 'HorizontalAlignment','left')
  6 Comments
DebiPrasad
DebiPrasad on 1 Nov 2017
Thanks very much. Star Strider. This is very helpful
Star Strider
Star Strider on 1 Nov 2017
As always, my pleasure.

Sign in to comment.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!