Generating Basic signals – Rectangular Pulse and Power Spectral Density using FFT

1 Star2 Stars3 Stars4 Stars5 Stars (12 votes, average: 4.58 out of 5)

Numerous texts are available to explain the basics of Discrete Fourier Transform and its very efficient implementation – Fast Fourier Transform (FFT).  Often we are confronted with the need to generate simple, standard signals (sine, cosineGaussian pulsesquarewaveisolated rectangular pulse, exponential decay, chirp signal) for simulation purpose. I intend to show (in a series of articles) how these basic signals can be generated in Matlab and how to represent them in frequency domain using FFT.

Rectangular Pulse: Mathematical Description

An isolated rectangular pulse of amplitude \(A\) and duration \(T\) is represented mathematically as

$$ g(t) = A \cdot rect( \frac{t}{T} ) $$


$$ rect(t) = \begin{cases}  1  & when \frac{-1}{2}<t<\frac{1}{2}\\ 0 & otherwise \end{cases}  $$

The Fourier transform of isolated rectangular pulse (\g(t)\) is

$$ G(f)=\int_{-T/2}^{T/2}A e^{-j2 \pi f t} dt = A \cdot \frac{sin(\pi f t)}{\pi f} = AT \cdot sinc(fT) $$

where, the \(sinc\) function is given by

$$ sinc(x)=\frac{sin(\pi x)}{\pi x} $$

Thus, the Fourier Transform pairs are

$$  A \cdot  rect( \frac{t}{T} ) \leftrightharpoons AT \cdot sinc(fT) $$

The Fourier Transform describes the spectral content of the signal at various frequencies. For a given signal \(g(t)\), the Fourier Transform is given by

$$ G(f) = \left |  G(f)  \right | e^{j \theta (f) } $$

where, the absolute value \(\left |  G(f)  \right |\) gives the magnitude of the frequency components (amplitude spectrum) and \(\theta (f)\) are their corresponding phase (phase spectrum) . For the rectangular pulse, the amplitude spectrum is given as

$$ \left |  G(f)  \right | = AT \left | sinc(fT)\right |  $$

The amplitude spectrum peaks at \(f=0\) with value equal to \(AT\). The nulls of the spectrum occur at integral multiples of \(1/T\), i.e, ( \( \pm 1/T, \pm 2/T, \pm 3/T, …  \) )

Generating an isolated rectangular pulse in Matlab:

An isolated rectangular pulse of unit amplitude and width \(w\) (the factor \(T\) in equations above ) can be generated easily with the help of in-built function – \(rectpuls(t,w)\) command in Matlab. As an example, a unit amplitude rectangular pulse of duration \(T=0.2 s\) is generated.

Rectangule Pulse how to plot FFT in Matlab

Amplitude spectrum using FFT:

Matlab’s FFT function is utilized for computing the Discrete Fourier Transform (DFT). The magnitude of FFT is plotted. From the following plot, it can be noted that the amplitude of the peak occurs at \(f=0\) with peak value  \(AT=1 \times 0.2=0.2\). The nulls in the spectrum are located at  ( \( \pm 1/T= \pm 5 Hz, \pm 2/T= \pm 10 Hz, \pm 3/T= \pm 15Hz, …  \) ).

Rectangule Pulse Magnitude of FFT

Power Spectral Density (PSD) using FFT:

The distribution of power among various frequency components is plotted next. The first plot shows the double-side Power Spectral Density which includes both positive and negative frequency axis. The second plot describes the PSD only for positive frequency axis (as the response is just the mirror image of negative frequency axis).

Rectangule Pulse Double Sided Power Spectral Density

Rectangule Pulse Single Sided Power Spectral Density

Rate this article: 1 Star2 Stars3 Stars4 Stars5 Stars (12 votes, average: 4.58 out of 5)


Articles in this series:
How to Interpret FFT results – complex DFT, frequency bins and FFTShift
How to Interpret FFT results – obtaining Magnitude and Phase information
FFT and Spectral Leakage
How to plot FFT using Matlab – FFT of basic signals : Sine and Cosine waves
Generating Basic signals – Square Wave and Power Spectral Density using FFT
Generating Basic signals – Rectangular Pulse and Power Spectral Density using FFT (this article)
Generating Basic Signals – Gaussian Pulse and Power Spectral Density using FFT
Chirp Signal – Frequency Sweeping – FFT and power spectral density
Constructing the Auto Correlation Matrix using FFT

 For more such examples check this ebook : Simulation of Digital Communications using Matlab – by Mathuranathan Viswanathan

Recommended Signal Processing Books