Why I could not convert time domain to frequency domain data?

1 次查看(过去 30 天)
Hi all; i try tho covert the time domain to frequency domain by using fft function, but the acceleration vs Frequency plot is incorrect. So kindly can anyone explain what is the wrong in the code. Thanks in advance
Lenght = size(x_time,2);
NFFT = 2^nextpow2(Lenght(1,1)-1); % Next power of 2 from length of b
Y1 = fft(Acc1,NFFT)/(Lenght(1,1)-1);
f = Fs/2*linspace(0,1,NFFT/2+1);
yPower1 = 2*abs(Y1(1:NFFT/2+1)); %magnitude
ydB1 = 20*log10(abs(Y1(1:NFFT/2+1))); %power
figure(51);
plot(f,yPower1);
xlabel('Frequency (Hz)','fontsize',14)
ylabel('Acc.','fontsize',14)
%axis ([0 10 0 10])
figure(61);
plot(f,ydB1);
xlabel('Frequency (Hz)','fontsize',14)
ylabel('Power (dB)','fontsize',14)
where x_time is the time vector Acc1 is the acceleration vector
  4 个评论
Star Strider
Star Strider 2017-3-15
That looks correct to me.
The details will be more apparent if you add this line after each plot:
set(gca, 'XLim',[0 30])
since there doesn’t appear to be anything above 30 Hz.
Muna Shehan
Muna Shehan 2017-3-16
Thanks for your comment.Based on your comment, the code for fft is correct even if the acceleration vs time profile is repeated sine wave signal as shown in the first plot .I followed your suggestion and the frequency response is as in the below plots.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Fourier Analysis and Filtering 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by