## evaluating SHORT TIME FOURIER TRANSFORM of a stationary signal

3.6K Downloads

Updated 9 Nov 2008

No License

the stationary signal

f(t)=cos(2*pi*5*t)+ cos(2*pi*10*t)+ cos(2*pi*20*t)+ cos(2*pi*50*t)

having frequencies of 5,10, 20and 50 Hz at any given time instant.

MATLAB program can be implemented to plot the stationary signal mentioned above:

Clear all;

Clf;

n=1:200;

y=cos(2*pi*5*n/200)+cos(2*pi*10*n/200)+cos(2*pi*20*n/200)+cos(2*pi*50*n/200);

plot(y);

/*sampling frequency (fs)=200hz

x[t]=x[n*Ts]

Sampling period(Ts)=(1/fs)*/

/*The same signal if is non-stationary in nature,i.e its frequency changes with time, from 5,10,20 to 50 hz.one frequency exists at a time.The non-stationary signal can be produced using the following MATLAB program:*/

N1=50;

m=1;

z=N1;

f=5;

for i=1:4

n=m:z;

x1(m:z)=cos(2*pi*(f/200)*n);

m=z+1;

z=m+N1-1;

if(i~=3)

f=f*2;

else

f=50;

end

end

The similarity between is that both of them show four spectral components at exactly the same frequencies, i.e., at 5,10, 20, 50.Other than the ripples, and the difference in amplitude (which can always be normalized), the two spectrums are almost identical, although the corresponding time-domain signals are not even close to each other. Both of the signals involve the same frequency components, but the first one has these frequencies at all times, the second one has these frequencies at different intervals. As the FT gives the spectral content of the signal, but it gives no information regarding where in time those spectral components appear . Therefore, FT is not a suitable technique for non-stationary signal.

In STFT, the signal is divided into small enough segments, where these segments (portions) of the signal can be assumed to be stationary. For this purpose, a window function "w" is chosen. The width of this window must be equal to the segment of the signal where its stationarity is valid.

This window function is first located to the very beginning of the signal. That is, the window function is located at t=0. Let's suppose that the width of the window is "T" s. At this time instant (t=0), the window function will overlap with the first T/2 seconds (I will assume that all time units are in seconds). The window function and the signal are then multiplied. By doing this, only the first T/2 seconds of the signal is being chosen, with the appropriate weighting of the window (if the window is a rectangle, with amplitude "1", then the product will be equal to the signal). Then this product is assumed to be just another signal, whose FT is to be taken. In other words, FT of this product is taken, just as taking the FT of any signal.

The result of this transformation is the FT of the first T/2 seconds of the signal. If this portion of the signal is stationary, as it is assumed, then there will be no problem and the obtained result will be a true frequency representation of the first T/2 seconds of the signal.

The next step, would be shifting this window (for some t1 seconds) to a new location, multiplying with the signal, and taking the FT of the product. This procedure is followed, until the end of the signal is reached by shifting the window with "t1" seconds intervals.

The following definition of the STFT summarizes all the above explanations in one line:

STFT(T,X)=INTEGRATION [ x(t) * w(t-t') * exp(-j*2*pi*f*t) ] dt

over t

Taking the previous example of the nonstationary signal whose frequency increases from

5,10,20 to 50 hz, we evaluate the STFT of that signal taking rectangular window of length 50,and shifting it for 1 unit each time,resulting into a highly overlapping window.

Thus we get the 3D plot of STFT of the signal.Amplitude-Frequency-Time curve.

### Cite As

payel mukherjee (2023). evaluating SHORT TIME FOURIER TRANSFORM of a stationary signal (https://www.mathworks.com/matlabcentral/fileexchange/22033-evaluating-short-time-fourier-transform-of-a-stationary-signal), MATLAB Central File Exchange. Retrieved .

##### MATLAB Release Compatibility

##### Platform Compatibility

Windows macOS Linux##### Categories

##### Tags

### Community Treasure Hunt

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

Start Hunting!### Discover Live Editor

Create scripts with code, output, and formatted text in a single executable document.

Version | Published | Release Notes | |
---|---|---|---|

1.0.0.0 |