AIM Objective: Digital Communication Simulation Using Matlab
AIM Objective: Digital Communication Simulation Using Matlab
INTRODUCTION:
AIM: To model and analyse the Communication System Using MATLAB
OBJECTIVE:
SCOPE:
Communication Systems:
Communication Systems can be defined as the systems which are designed to
transmit information. Basically there are two types of communication systems namely
Analog Communication Systems and Digital Communication Systems. An Analog
Communication System is used to transmit the analog information while the Digital
Communication System is used to transmit the digital information. Regardless of any
particular information any communication system consists of three main subsystems
namely transmitter, channel and receiver.[ CITATION Leoon \l 2057 ]
1037089 Page 1
[DIGITAL COMMUNICATION SIMULATION USING MATLAB] December 7, 2010
The [~] indicates that the received signal is not the same as the transmitted signal.
The transmitter carrier circuit converts the processed baseband signal into a
frequency band that is appropriate for the transmission medium of the channel. Carrier
circuits are needed when the transmission channel is located in a band of frequencies
around fc where fc >> 0. fc is the carrier frequency. Here s(t) is the band pass signal. [ CITATION
Leoon \l 2057 ]
Channels can be categorized into two types, hard wire and soft wire. Examples of
hard wire channels are coaxial-cables, wave guides, twisted pair telephone lines, fiber
optical cables etc. Examples of soft wire channels are air, vacuum and sea-water. The
channels contain active amplifying devices, such as repeaters in telephone line systems or
satellite transponders in space communication systems which helps to keep the signal
above the noise level. [ CITATION Leoon \l 2057 ]
The receiver receives the corrupted signal from the channel output and converts into
baseband signal which can be handled by the receiver base band processor. This signal is
cleaned by the base band processor and delivers the estimate of the source information to
the communication system output.[ CITATION Leoon \l 2057 ]
1037089 Page 2
[DIGITAL COMMUNICATION SIMULATION USING MATLAB] December 7, 2010
Spectrum Analysis:
Examination of signals in the frequency domain is one of the most important
measurement tasks in radio communications. The most versatile and widely used RF
measuring instruments required for this purpose are Spectrum analyzers. Covering
frequency ranges of up to 40 GHz and beyond, they are used in practically all applications of
wireless and wired communication in development, production, installation and
maintenance efforts. With the growth of mobile communications, parameters such as
displayed average noise level, dynamic range and frequency range, and other exacting
requirements regarding functionality and measurement speed come to the fore. Moreover,
spectrum analyzers are also used for measurements in the time domain, such as measuring
the transmitter output power of time multiplex systems as a function of time. [ CITATION
Rau08 \l 2057 ]
The general frame of reference is Time. In the time domain the amplitude of
electrical signals is plotted versus time. An oscilloscope is used to see the instantaneous
value of a particular electrical event (or some other event converted to volts through an
appropriate transducer) as a function of time. [ CITATION unk10 \l 2057 ]
According to the Fourier theorem, any signal that is periodic in the time domain can
be derived from the sum of sine and cosine signals of different frequency and amplitude.
Such a sum is referred to as a Fourier series.[ CITATION Rau08 \l 2057 ]
With proper filtering any waveform can be decomposed into separate sine waves, or
spectral components, that can be evaluated independently later. A Spectrum can be defined
as the collection of sine waves that, when combined properly, produce the time-domain
signal.[ CITATION unk10 \l 2057 ]
The frequency domain has its measurement strengths. The frequency domain is
better for determining the harmonic content of a signal. Communications people are
1037089 Page 3
[DIGITAL COMMUNICATION SIMULATION USING MATLAB] December 7, 2010
generally more interested in harmonic distortion. Consider an example, where cellular radio
systems are checked for harmonics of the carrier signal which might interfere with other
system operating at the same frequencies as the harmonics. Communications people are
also interested in distortion of the message modulated onto a carrier. Third-order inter
modulation (two tones of a complex signal modulating each other) can be particularly
troublesome because the distortion components can fall within the band of interest and so
not be filtered away.[ CITATION unk10 \l 2057 ]
FFT:
“FFT is abbreviated as Fast Fourier Transform. It is considered to be an efficient
algorithm to compute the Discrete Fourier Transform (DFT) and its inverse.
1037089 Page 4
[DIGITAL COMMUNICATION SIMULATION USING MATLAB] December 7, 2010
transform we would not be able to compute the Fourier transform with a microprocessor or
DSP based system.”[ CITATION unk \l 2057 ]
“The DFT is NOT the same as the DTFT (Discrete Time Fourier Transform). Both start
with a discrete-time signal, but the DFT produces a discrete frequency domain
representation while the DTFT is continuous in the frequency domain. These two transforms
have much in common, however.”[ CITATION unk \l 2057 ]
“The FFT does not directly give the spectrum of a signal. The FFT varies dramatically
depending on the number of points (N) of the FFT, and the number of periods of the signal
that are represented. There is another problem as well. The FFT contains information
between 0 and fs, however, the sampling frequency must be at least twice the highest
frequency component. Therefore, the signal's spectrum should be entirely below fs/2 , the
Nyquist frequency.” [ CITATION unk \l 2057 ]
The FFT operates by decomposing an N point time domain signal into N time domain
signals each composed of a single point. The second step is to calculate the N frequency
spectra corresponding to these N time domain signals. Lastly, the N spectra are synthesized
into a single frequency spectrum.[ CITATION unk104 \l 2057 ]
“This method is efficient because it reduces the redundancies which result from
adding the certain data sequence values after they have been multiplied by the same factors
of fixed complex constants during the evaluation of different DFT transform
coefficients.”[ CITATION Dou87 \l 2057 ]
Cooley-Tukey algorithm is one of the best algorithm used to compute the N point
DFT when N is composite (i.e. when N 1N2). In this case it first computes the N 1 transforms of
size N2 and then N2 transforms of size N1.
The fft command in Matlab is used to evaluate DTFS and find the time-bandwidth
product property for discrete-time periodic signals. Since DFTS applies to signals that are
periodic both in time and frequency, both the duration and bandwidth for the signal within
one period are to be defined.[ CITATION Sim99 \l 2057 ]
1037089 Page 5
[DIGITAL COMMUNICATION SIMULATION USING MATLAB] December 7, 2010
FFTSHIFT:
“FFTSHIFT rearranges the fft output, moving the zero frequency to the center of the
spectrum. The sequence can be given as y=fftshift(x [,job])
y= fftshift(x,n) make the swap only along the nth dimension.” [ CITATION unk101 \l 2057 ]
“In the formula y=fftshift(x)
Input x is a two-dimensional array or a vector, typically the output of fft of fft2.
Output y is an array of the same size as the input. The output contains the same elements
but in a different order.
For a one-dimensional array, the element x[k+1] of the output x of fft is the
transform of the input at the frequency exp(2*pi*i*k/N), k=0,1,...N-1 where N is the size of x
. Likewise, the element z[j+1,k+1] of the output z of fft2 is the transform of the input at the
frequencies exp(2*pi*i*j/M), exp(2*pi*i*k/N) with j=0,1,...M-1 , and k=0,1,...N-1 . Here M
and N are the row and column dimensions of y.
fftshift rearranges the outputs of fft and fft2 so that the zero frequency is at the
center of the spectrum. If the input is a vector, fftshift swaps the upper and lower half of the
1037089 Page 6
[DIGITAL COMMUNICATION SIMULATION USING MATLAB] December 7, 2010
vector. If the input is a matrix, the first and third quadrants as well as the second and fourth
quadrants are swapped.”[ CITATION unk102 \l 2057 ]
>> fs=100;
1037089 Page 7
[DIGITAL COMMUNICATION SIMULATION USING MATLAB] December 7, 2010
>> t=0:1/fs:1;
>> y=cos(2*pi*t);
>> Y=fft(y);
Now to map the x-axis value to reflect frequency in Hz, i.e. to get the positive and negative
frequencies
>> k=-N/2:N/2-1;
1037089 Page 8
[DIGITAL COMMUNICATION SIMULATION USING MATLAB] December 7, 2010
1037089 Page 9
[DIGITAL COMMUNICATION SIMULATION USING MATLAB] December 7, 2010
The syntax for computing the FFT of a signal is given by fft(x,N) where x is the signal,
x[n] which we wish to transform and ‘N’ is the number of points in the FFT. Generally ‘N’
must be larger than the number of samples in x[n].
This task is performed to observe the effect of ‘N’ on the FFT signal when ‘N’ is equal
and less than the number of samples in x[n]. It is observed by the following example
Code Program:
n=[0:29];
X=cos(2*pi*n/10);
N1=30;
N2=25;
X1=abs(fft(X,N1));
X2=abs(fft(X,N2))
F1=[0:N1-1]/N1;
F2=[0:N2-1]/N2;
subplot(2,1,1)
plot(F1,X1,'-x')
title('when N=n')
axis([0 1 0 20])
subplot(2,1,2)
plot(F2,X2,'-x')
1037089 Page 10
[DIGITAL COMMUNICATION SIMULATION USING MATLAB] December 7, 2010
title('when N<n')
axis([0 1 0 20])
“When the FFT is computed with an N larger than the number of samples in x[n], it
fills in the samples after x[n] with zeros. When Matlab computes the FFT, it automatically
fills the spaces with zeros from n to N-1 if ‘N’ is greater than ‘n’. This is like taking a sinusoid
and multiplying it with a rectangular box of length ‘n’. A multiplication of a box and a
sinusoid in the time domain would result in the convolution of a sinc with impulses in the
frequency domain. Furthermore, increasing the width of the box in the time domain would
increase the frequency of the sinc in the frequency domain.” [ CITATION unk \l 2057 ]
The above figure depicts two subplots. The first subplot shows the FFT of a Cosine
Signal when the number of samples in the signal is equal to the number of points in the FFT.
As the number of points is equal to the number of samples then the FFT of a Cosine results
in the two triangular wave forms with the center of the first triangular wave form is at 0.1f s
and the second at 0.9fs. Since the number of points is equal to the number of samples it
doesn’t require zeros to be added.
1037089 Page 11
[DIGITAL COMMUNICATION SIMULATION USING MATLAB] December 7, 2010
The second subplot shows the FFT of a Cosine Signal when the number of samples in
the signal is greater than the number of points in the FFT. When the number of points in
the FFT is less than the samples of the signal then the amplitude of FFT signal gets lowered
which can be clearly observed in the above figure second subplot. This also results in the
irregular shaped two triangular waveforms with the center of the first waveform at 0.1f s and
the second at 0.9fs.
Code Program:
n=[0:35];
X1=cos(2*pi*n/12);
X2=[X1 X1];
X3=[X1 X1 X1];
X4=[X1 X1 X1 X1];
N=2048;
Y1=abs(fft(X1,N));
Y2=abs(fft(X2,N));
Y3=abs(fft(X3,N));
Y4=abs(fft(X4,N))
F=[0:N-1]/N;
1037089 Page 12
[DIGITAL COMMUNICATION SIMULATION USING MATLAB] December 7, 2010
subplot(2,2,1)
plot(F,Y1,'-x')
title('for 3 periods')
subplot(2,2,2)
plot(F,Y2,'-x')
title('for 6 periods')
subplot(2,2,3)
plot(F,Y3,'-x')
title('for 9 periods')
subplot(2,2,4)
plot(F,Y4,'-x')
title('for 12 periods')
1037089 Page 13
[DIGITAL COMMUNICATION SIMULATION USING MATLAB] December 7, 2010
The code results in the 4 subplots as shown in the above figure. The first
subplot shows the transform of 3 periods of a Cosine signal, and it looks like the
magnitude of 2 Sincs with the center of the first Sinc at 0.1fs and the second at 0.9fs.
The second sub plot also looks like a Sinc, but with a higher frequency and with a
larger magnitude at 0.1fs and 0.9fs. Similarly, the third and the fourth subplots have
the larger Sinc frequencies and magnitudes. This clearly shows that as x[n] is
extended to the large number of periods, the Sincs will start looking more and more
like impulses.[ CITATION unk \l 2057 ]
“The FFT doesn’t give directly the spectrum of a signal. The last two experiments
clearly explain that, the FFT varies dramatically with the number of points (N) of the FFT,
and the number of periods of the signal that are represented. There is another problem as
well.
The FFT contains information between 0 and fs, however, it is known that the
sampling frequency must be at least twice the highest frequency component. Therefore, the
signal's spectrum should be entirely below fs/2, the Nyquist frequency.
Also a real signal should have a transform magnitude that is Symmetrical for positive
and negative frequencies. So instead of having a spectrum that goes from 0 to fs, it would
be more appropriate to show the spectrum from –fs/2 to fs/2 . This can be achieved by
using Matlab's fftshift function as the following code demonstrates.” [ CITATION unk \l 2057 ]
Code Program:
n=[0:209];
X=cos(2*pi*n/10)+sin(3*pi*n/10);
N=2048;
X1=abs(fft(X,N));
X2=fftshift(X1);
1037089 Page 14
[DIGITAL COMMUNICATION SIMULATION USING MATLAB] December 7, 2010
F= [-N/2:N/2-1]/N;
plot(F,X2,'-x')
title('fftshift signal')
xlabel('frequency')
ylabel('amplitude')
In the above figure the spectrum of the FFT of the Sum of the Cosine and Sine Signal
is spread around the center 0 which can be observed clearly in the above figure. The
spectrum looks like a symmetrical signal around the zero frequency. There are four peaks
two on either side of the zero frequency and it almost looks like an impulse signal. With the
increase of the length of the window, the sinc function almost looks like an impulse signal.
1037089 Page 15
[DIGITAL COMMUNICATION SIMULATION USING MATLAB] December 7, 2010
Conclusion:
By observing all the three above tasks it can be concluded saying that Matlab is a
powerful numerical computing environment and programming tool. Matlab is used in real
time applications like in wireless digital communication systems to design and analyse the
spectrum of the different FFT signals. The fft command in the Matlab is considered to be the
powerful function to perform the DFT of the signal. The analysis in the frequency domain is
very useful and provides the clear understanding of the signal compared to the time
domain analysis.
It is observed that the change in the number of points (N) in the FFT, number of
samples of the signal and the number of repetitions of the fundamental period affect the
shape of the spectrum of the signal. The basic required condition is that, the number of
points in the FFT should be equal or greater than the number of samples in the signal.
It is also studied with the increase in the number of periods the sinc pulse turns into
nearly to the shape of the impulse which is the required criteria.
1037089 Page 16
[DIGITAL COMMUNICATION SIMULATION USING MATLAB] December 7, 2010
References:
El-Osery, A. (October 27, 2004). Fast Fourier Transform. MATLAB Tutorial , 18.
Rauscher, C. (2008). Fundamentals of Spectrum Analysis. Germany: Rohde & Schwarz GmbH & Co.
KG.
unknown. (n.d.). Agilent Spectrum Analysis Basics. Retrieved december 01, 2010, from
www.google.com.
unknown. (n.d.). Fast Fourier Transform. Retrieved december 1st, 2010, from www.wikipedia.com:
http://en.wikipedia.org/wiki/Fast_Fourier_transform
unknown. (n.d.). Fast Fourier Transform. Retrieved december 1st, 2010, from www.dspguide.com:
http://www.dspguide.com/ch12/2.htm
unknown. (n.d.). Help for fftshift. Retrieved december 1st, 2010, from www.google.com:
http://www.mathnium.com/help/fftshift.html
unknown. (n.d.). Scilab Reference Manual. Retrieved december 1st, 2010, from www.google.com:
http://cermics.enpc.fr/~jpc/mopsi/doc/fftshift.html
Veen, S. H. (1999). Signals and Systems. Newyork: John Wiley & Sons.
W.Couch, L. (fifth edition). Digital and Analog Communication Systems. USA: Prentice Hall.
1037089 Page 17
[DIGITAL COMMUNICATION SIMULATION USING MATLAB] December 7, 2010
Bibliography
Rauscher, C. (2008). Fundamentals of Spectrum Analysis. Germany: Rohde & Schwarz GmbH & Co.
KG.
Veen, S. H. (1999). Signals and Systems. Newyork: John Wiley & Sons.
W.Couch, L. (fifth edition). Digital and Analog Communication Systems. USA: Prentice Hall.
1037089 Page 18