plotting fft of frequency varying signal

11 次查看(过去 30 天)
Hello
I'm trying to plot the frequency spectrum two signals y1[1] and y2[n] which both last for 3s each. y1[n] is the sum of 3 sinusoids present all the time with frequencies (10, 25 and 50 Hz). y2[n] is the concatenation of the three tones contained in y1[n], each tone last 1 second ie 10Hz from t=0s to t=1s, 25Hz from t=1s to t=2s and 50Hz for the last second. My fft fuction works perfectly for y1 but displays odd results for y2. I expect to see the three tones at 10, 25 and 50 Hz on the frequency spectrum with an amplitude of 1 but the frequncy spectrum of y2 shows the three tones at the correct frequency but the aplitude is wrong. How can i plot y2 correctly? I have included my fft code and the spectrums I plotted.
function do_fft(x,Fs,L)
FT=fft(x);
P2 = abs(FT/L);
P1 = P2(1:L/2+1);
P1(2:end-1) = 2*P1(2:end-1);
f = Fs*(0:(L/2))/L;
%figure
plot(f,P1)
title('Single-Sided Amplitude Spectrum of x(n)')
xlabel('f (Hz)')
ylabel('|amplitude|')

回答(1 个)

Nagasai Bharat
Nagasai Bharat 2020-8-25
Hi James,
As per my understanding you are trying to plot the Normalized Fourier transform of a concatenated sine wave having a different frequency at each second of the total 3 second interval. The odd result you are getting is due to the incorrect value of the length of the frequency spectrum you are considering. As only one third of the total signal a unique sine wave is present, the total length of the FFT is also reduced by third.

类别

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