short time fourier transform

조회 수: 6 (최근 30일)
Richard
Richard 2012년 12월 9일
I would like to perform a short time fourier transform (STFT) to a synthetic data series. I can compute the fourier transform by:
fs = 40;
t = 0:(1 / fs):4;
y1 = [sin(2 * pi * 5 * t(t <= 2)), sin(2 * pi * 10 * t(t > 2))];
subplot(311);
plot(t,y1,'k');
Fy1 = abs(ifft(y1));
N = numel(t);
idx = 1:numel(Fy1) / 2; % # Indices of half the spectrum
f = fs * (0:(N - 1)) / N; % # Actual frequencies
subplot(312);
plot(f(idx),2*Fy1(idx),'k');
As a third subplot, I would now like to compute the STFT otherwise known as the windowed fourier transform, which will show hoe the frequency of the signal varies in time. How can this be done?

답변 (3개)

Matt J
Matt J 2012년 12월 9일
  댓글 수: 2
Richard
Richard 2012년 12월 13일
what about the spectrogram, is this better?
Matt J
Matt J 2012년 12월 13일
Once you have the STFT, you can obtain the spectrogram as abs(STFT).^2

댓글을 달려면 로그인하십시오.


Wayne King
Wayne King 2012년 12월 13일
Why not just use spectrogram if you have the Signal Processing Toolbox?
You can output the STFT and/or the short-time periodograms (PSD estimates)
  댓글 수: 1
Richard
Richard 2012년 12월 13일
I have tried using the spectrogram. By typing spectrogram(y1), matlab returns a plot, but I cannot get the spectrogram to display the results in a format that follows from subplot(311) and (312) above. For example, I would like the time along the x axis and the frequency along the y.

댓글을 달려면 로그인하십시오.


Wayne King
Wayne King 2012년 12월 13일
Then just use the 'yaxis' option
t = 0:0.001:1-0.001;
x=chirp(t,0,1,150);
spectrogram(x,'yaxis')
If you actually output arguments from spectrogram, you have much more control over the plot. See the help.

Community Treasure Hunt

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

Start Hunting!

Translated by