signal processing, fft, adding two cosine waves
Show older comments
Hi, I can individually retrieve the magnitude and frequency of two cosine waves (say 10*cos(w*t) and 30*cos(w*t)). Suppose the signal is 10*cos(w*t)+30*cos(w*t) how to retrieve the magnitudes (i.e, 10 and 30) from the fft. All suggestions welcome.
Accepted Answer
More Answers (1)
Wayne King
on 6 May 2012
The main thing will be figuring out the DFT bin that the frequency of interest falls on. The frequencies are spaced at Fs/N where N is the length of the input signal and Fs is the sampling frequency. Keep in mind that the first bin (unless you use fftshift) is the zero frequency, or DC. I'll do an example assuming a sampling frequency of 1 and two frequencies, 1/8 cycles/sec and 1/4 cycles per second. For a signal of length 200, we expect these frequencies in bins, 26 and 51.
n = 0:199;
x = 10*cos(pi/4*n)+30*sin(pi/2*n);
xdft = fft(x);
xdft = xdft(1:length(x)/2+1)/length(x);
xdft(2:end-1) = 2*xdft(2:end-1);
plot(abs(xdft))
abs(xdft(26))
abs(xdft(51))
Categories
Find more on Transforms 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!