0% found this document useful (0 votes)
129 views18 pages

AIM Objective: Digital Communication Simulation Using Matlab

This document discusses digital communication system simulation using MATLAB. It aims to model and analyze communication systems using MATLAB commands like FFT and FFTSHIFT. The objectives are to study MATLAB basics, perform time-continuous and spectrum analysis using FFT functions. The document introduces communication systems and their components like transmitter, channel, and receiver. It describes analog and digital communication systems. It also discusses spectrum analysis and the FFT algorithm for efficiently computing the discrete Fourier transform. The FFT decomposes a time domain signal into its frequency domain representation.

Uploaded by

hari423
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
129 views18 pages

AIM Objective: Digital Communication Simulation Using Matlab

This document discusses digital communication system simulation using MATLAB. It aims to model and analyze communication systems using MATLAB commands like FFT and FFTSHIFT. The objectives are to study MATLAB basics, perform time-continuous and spectrum analysis using FFT functions. The document introduces communication systems and their components like transmitter, channel, and receiver. It describes analog and digital communication systems. It also discusses spectrum analysis and the FFT algorithm for efficiently computing the discrete Fourier transform. The FFT decomposes a time domain signal into its frequency domain representation.

Uploaded by

hari423
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 18

[DIGITAL COMMUNICATION SIMULATION USING MATLAB] December 7, 2010

INTRODUCTION:
AIM: To model and analyse the Communication System Using MATLAB

OBJECTIVE:

1) Study of the Matlab basics


2) Study of fft and fftshift commands
3) Performing time-continuous signal analysis
4) Performing spectrum analysis using the FFT functions

SCOPE:

1) MATLAB has a wide scope in Wireless Communication Systems


2) In Signal and Image processing, communications, control design, test and
measurement, financial modelling and analysis, and computational biology

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 ]

Fig 1: Basic Communication System[ 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.

In analog communication system the Signal Processing block (processor) may be an


analog low-pass filter which is used to limit the band-width of m(t) which is the input
information signal. In digital communication system the Signal processor may be Analog to
Digital Converter (ADC) which is used to convert the analog signals into digital signals. In
addition the Signal Processor also provides source coding of the input signals. It also adds
parity bits to provide the channel coding by which error detection and correction can be
made possible at the receiver to eliminate the bit errors introduced by the noise in the
channel. The transmitter signal processor output signal is the base-band signal because it
has the frequencies concentrated around the f=0.[ CITATION Leoon \l 2057 ]

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 ]

The communication systems which use atmosphere as the transmission channel,


interference and propagation conditions are strongly dependent on the transmission
frequency. [ 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 ]

Spectrum analysis is the process of determining the frequency domain


representation of a time domain signal and most commonly employs the Fourier transform.

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 ]

[ 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 ]

A practical quantitative assessment of the higher-order harmonics is not possible in


the Time domain analysis of a signal. In the frequency domain it is much easier to examine the
short-term stability of frequency and amplitude of a sinusoidal signal compared to the time
domain. [ CITATION Rau08 \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.

A DFT decomposes a sequence of values into components of different frequencies.


This operation is useful in many fields, but computing it directly from the definition is often
too slow to be practical. An FFT is a way to compute the same result more quickly:
computing a DFT of N points in the simple way, using the definition, takes O(N2) arithmetical
operations, while an FFT can compute the same result in only O(N log N) operations. The
difference in speed can be substantial, especially for long data sets where N may be in the
thousands or millions—in practice, the computation time can be reduced by several orders
of magnitude in such cases, and the improvement is roughly proportional to N / log(N). This
huge improvement made many DFT-based algorithms practical; FFTs are of great
importance to a wide variety of applications, from digital signal processing and solving
partial differential equations to algorithms for quick multiplication of large
integers.”[ CITATION unk103 \l 2057 ]

“The DFT is extremely important in the area of frequency (spectrum) analysis


because it takes a discrete signal in the time domain and transforms that signal into its
discrete frequency domain representation. Without a discrete-time to discrete-frequency

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

If we compute the Fourier transform of a sine or a cosine function we expect to see


two impulses at the frequency of the sine or the cosine. But, they cannot be seen. This can
be achieved by using fftshift function.[ CITATION Aly04 \l 2057 ]

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])

The parameters, x: real or complex vector or matrix

y: real or complex vector or matrix

job: integer, dimension selection, or string ‘all’

1) If x results of an fft computation y= fftshift(x) or y= fftshift(x,"all") moves the zero


frequency component to the center of the spectrum, which is sometimes a more
convenient form.
2) If x is a vector of size n, y is the vector x([n/2+1:n,1:n/2])
3) If x is an m by n matrix y is the matrix x([m/2+1:n,1:m/2],[n/2+1:n,1:n/2]).

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.

The description is given as

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 ]

Example:[ CITATION unk102 \l 2057 ]


>>y=rand(1024,1);
>>z=fft(y)
>>subplot(2,1,1)
>>plot(abs(z))
>>title("FFT")
>>w=fftshift(z)
>>subplot(2,1,2)
>>plot(abs(w))
>>title("FFTHIFT")

[ CITATION unk102 \l 2057 ]

Figure 2: fft and fftshift

It is helpful in visualizing a Fourier transform with the zero-frequency component in


the middle of the spectrum.

Consider an another example [ CITATION Aly04 \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);

>> plot(fftshift(abs(Y))) % gives the Figure 3

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;

>> plot(k,fftshift(abs(Y))) % gives the Figure 4

Now to map it to actual frequencies

>> plot(k*fs/N,fftshift(abs(Y))) % gives the Figure 5

[ CITATION Aly04 \l 2057 ]

Figure 3: fftshift signal

1037089 Page 8
[DIGITAL COMMUNICATION SIMULATION USING MATLAB] December 7, 2010

[ CITATION Aly04 \l 2057 ]


Figure 4: fftshift with k= -N/2 : N/2-1

[ CITATION Aly04 \l 2057 ]

Figure 5: Frequency mapping

1037089 Page 9
[DIGITAL COMMUNICATION SIMULATION USING MATLAB] December 7, 2010

Task 1: FFT of a Cosine when N=n & N<n


Matlab’s Fast Fourier Transform (FFT) function is a very powerful tool for computing
the Discrete Fourier Transform (DFT) of a signal.

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])

This program results in the following figure 6

Figure 6: FFT of a Cosine Signal when N=n & N<n

“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.

Task 2: FFT of a Cosine Signal with 3, 6, 9 & 12 Periods


In the previous task the number of periods is considered as 3 with the number of FFT
points as N=30 and N=25. Now in this task taking N=2048 the number of repetitions of the
fundamental period is varied. 3 periods, 6 periods, 9 periods and 12 periods of a Cosine
Signal in length are considered.

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')

This code results in the following figure 7

Figure 7: FFT of a Cosine with 3, 6, 9 and 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 ]

Task 3: Spectrum of an FFT signal using fftshift


“If we compute the Fourier transform of a sine or a cosine function we expect to see
two impulses at the frequency of the sine or the cosine. But, that's not what we are
seeing.”[ CITATION Aly04 \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')

This Code results the following figure 8

Figure 8: fftshift of a Sum of Cosine Signal and Sine Signal

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.

fftshift command in the Matlab is used to shift zero-frequency component to center


of spectrum. It is studied in the task 3 that the fftshift shifts the spectrum with 0 as the
center of the spectrum looking like symmetric signals on either side.

1037089 Page 16
[DIGITAL COMMUNICATION SIMULATION USING MATLAB] December 7, 2010

References:

El-Osery, A. (October 27, 2004). Fast Fourier Transform. MATLAB Tutorial , 18.

F.Elliot, D. (1987). Handbook of Digital Signal Processing Enginnering Applications. California:


Acadaemic Press.

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.). FFT Tutorial. ELE 436: Communication Systems , 6.

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

F.Elliot, D. (1987). Handbook of Digital Signal Processing Enginnering Applications. California:


Acadaemic Press.

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

You might also like