Azzera filtri
Azzera filtri

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

1 visualizzazione (ultimi 30 giorni)
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 Commenti
Star Strider
Star Strider il 15 Mar 2017
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 il 16 Mar 2017
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.

Accedi per commentare.

Risposte (0)

Categorie

Scopri di più su Fourier Analysis and Filtering in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by