STFT of one particular frequency
3 views (last 30 days)
Show older comments
How can I compute and plot an STFT of a signal and extract only data of one frequency not the whole spectrum?
0 Comments
Answers (1)
Wayne King
on 25 Apr 2013
Edited: Wayne King
on 25 Apr 2013
Each row in the output of spectrogram() is the information at one DFT bin as a function of the time segments.
Fs = 1000;
t = 0:1/Fs:5-1/Fs;
x = cos(2*pi*100*t).*(t<1)+randn(size(t));
[xhat,f,T,psd_est] = spectrogram(x,200,150,200,Fs);
Now, you just select the row of the xhat (complex-valued) or psd_est matrix that contains your frequency of interest. Here I'll select 100 Hz.
plot(T,psd_est(21,:))
You see that 100 Hz essentially drops out after T = 1 second, which is exactly what we expect.
0 Comments
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!