plotting fft of frequency varying signal
5 views (last 30 days)
Show older comments
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|')
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/283218/image.jpeg)
0 Comments
Answers (1)
Nagasai Bharat
on 25 Aug 2020
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.
0 Comments
See Also
Categories
Find more on Fourier Analysis and Filtering 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!