Problems with Matlab Projects? You may face many Problems, but do not worry we are ready to solve your Problems. All you need to do is just leave your Comments. We will assure you that you will find a solution to your project along with future tips. On Request we will Mail you Matlab Codes for Registered Members of this site only, at free service...Follow Me.

Time Fourier Transform

Summary: Introduction to the Short Time Fourier Transform, which includes it's definition and methods for its use.





Short Time Fourier Transform

The Fourier transforms (FT, DTFT, DFT, etc.) do not clearly indicate how the frequency content of a signal changes over time.
That information is hidden in the phase - it is not revealed by the plot of the magnitude of the spectrum.

NOTE: 

To see how the frequency content of a signal changes over time, we can cut the signal into blocks and compute the spectrum of each block.
To improve the result,
  1. blocks are overlapping
  2. each block is multiplied by a window that is tapered at its endpoints.
Several parameters must be chosen:
  • Block length, R.
  • The type of window.
  • Amount of overlap between blocks. (Figure 1)
  • Amount of zero padding, if any.
Figure 1
STFT: Overlap Parameter
STFT: Overlap Parameter (stftfigs.png)
The short-time Fourier transform is defined as

X(ω,m)=(STFT(x(n)),,DTFT(x(nm)w(n)))
=
n=
 (x(nm)w(n)(ωn))
=
R1
n=0
 (x(nm)w(n)(ωn))
(1)
where w(n) is the window function of length R.
  1. The STFT of a signal x(n) is a function of two variables: time and frequency.
  2. The block length is determined by the support of the window function w(n).
  3. A graphical display of the magnitude of the STFT, |X(ω,m)|, is called the spectrogram of the signal. It is often used in speech processing.
  4. The STFT of a signal is invertible.
  5. One can choose the block length. A long block length will provide higher frequency resolution (because the main-lobe of the window function will be narrow). A short block length will provide higher time resolution because less averaging across samples is performed for each STFT value.
  6. narrow-band spectrogram is one computed using a relatively long block length R, (long window function).
  7. wide-band spectrogram is one computed using a relatively short block length R, (short window function).

Sampled STFT

To numerically evaluate the STFT, we sample the frequency axis ω in N equally spaced samples from ω=0 to ω=2π.
k,0kN1:(ωk=
2π
N
 k)(2)
We then have the discrete STFT,

(Xd(k,m),,X(
2π
N
 k,m))
=
R1
n=0
 (x(nm)w(n)(ωn))
=
R1
n=0
 (x(nm)w(n)WN(kn))
=DFTN(x(nm)w(n)|n=0R1,0,…0)
(3)
where 0,…0 is NR.
In this definition, the overlap between adjacent blocks is R1. The signal is shifted along the window one sample at a time. That generates more points than is usually needed, so we also sample the STFT along the time direction. That means we usually evaluate Xd(k,Lm) where L is the time-skip. The relation between the time-skip, the number of overlapping samples, and the block length is Overlap=RL

EXERCISE 1

Match each signal to its spectrogram in Figure 2.
Figure 2
(a)
Figure 2(a) (sgrams1.png)
(b)
Figure 2(b) (sgrams2.png)

Spectrogram Example

Figure 3
Figure 3 (stft_x.png)
Figure 4
Figure 4 (stft_256.png)
The matlab program for producing the figures above (Figure 3 and Figure 4).

   

   % LOAD DATA
   load mtlb;
   x = mtlb;

   figure(1), clf
   plot(0:4000,x)
   xlabel('n')
   ylabel('x(n)')

   % SET PARAMETERS
   R = 256;               % R: block length
   window = hamming(R);   % window function of length R
   N = 512;               % N: frequency discretization
   L = 35;                % L: time lapse between blocks
   fs = 7418;             % fs: sampling frequency
   overlap = R - L;

   % COMPUTE SPECTROGRAM
   [B,f,t] = specgram(x,N,fs,window,overlap);

   % MAKE PLOT
   figure(2), clf
   imagesc(t,f,log10(abs(B)));
   colormap('jet')
   axis xy 
   xlabel('time')
   ylabel('frequency')
   title('SPECTROGRAM, R = 256')

   
 

Effect of window length R

Figure 5
Narrow-band spectrogram: better frequency resolution
Narrow-band spectrogram: better frequency
     resolution (stft_512.png)
Figure 6
Wide-band spectrogram: better time resolution
Wide-band spectrogram: better time resolution
    (stft_128.png)
Here is another example to illustrate the frequency/time resolution trade-off (See figures - Figure 5Figure 6, and Figure 7).
Figure 7
Effect of Window Length R
(a)
Figure 7(a) (sgramsR_1.png)
(b)
Figure 7(b) (sgramsR_2.png)

Effect of L and N

A spectrogram is computed with different parameters: L{1,10} N{32,256}
  • L = time lapse between blocks.
  • N = FFT length (Each block is zero-padded to length N.)
In each case, the block length is 30 samples.

EXERCISE 2

For each of the four spectrograms in Figure 8 can you tell what L and N are?
Figure 8
(a)
Figure 8(a) (sgramsLN_1.png)
(b)
Figure 8(b) (sgramsLN_2.png)
L and N do not effect the time resolution or the frequency resolution. They only affect the 'pixelation'.

Effect of R and L

Shown below are four spectrograms of the same signal. Each spectrogram is computed using a different set of parameters. R{120,256,1024} L{35,250} where
  • R = block length
  • L = time lapse between blocks.

EXERCISE 3

For each of the four spectrograms in Figure 9, match the above values of L and R.
Figure 9
Figure 9 (stft.png)
If you like, you may listen to this signal with the soundsc command; the data is in the file: stft_data.mHere is a figure of the signal.
Figure 10
Figure 10 (stft_signal.png)

Content actions

GIVE FEEDBACK:

0 comments:

Post a Comment

Recent Comments

Popular Matlab Topics

Share your knowledge - help others

Crazy over Matlab Projects ? - Join Now - Follow Me

Sites U Missed to Visit ?

Related Posts Plugin for WordPress, Blogger...

Latest Articles

Special Search For Matlab Projects

MATLAB PROJECTS

counter

Bharadwaj. Powered by Blogger.