signal processing, fft, adding two cosine waves
Ältere Kommentare anzeigen
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.
Akzeptierte Antwort
Weitere Antworten (1)
Wayne King
am 6 Mai 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))
1 Kommentar
Nani C
am 6 Mai 2012
Kategorien
Mehr zu Transforms finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!