signal processing, fft, adding two cosine waves

5 次查看(过去 30 天)
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.

采纳的回答

Wayne King
Wayne King 2012-5-6
Then the magnitude will be 40 in this case if the frequencies and phases are the same. And there is no way to extract the 10 and the 30 separately.
n = 0:199;
x = 10*cos(pi/4*n)+30*cos(pi/4*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))

更多回答(1 个)

Wayne King
Wayne King 2012-5-6
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))

类别

Help CenterFile Exchange 中查找有关 Spectral Estimation 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by