Upload
hari423
View
228
Download
0
Embed Size (px)
Citation preview
8/7/2019 Report of Matlab
1/18
[DIGITAL COMMUNICATION SIMULATION USING MATLAB] December 7, 2010
1037089 Page 1
INTRODUCTION :
AIM: To model and analyse the Communication System Using MATLAB
OBJECTIVE:
1) Study ofthe Matlab basics
2) Study offft andfftshift commands
3) Performing time-continuous signal analysis
4) Performing spectrum analysis using the FFTfunctions
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. (W.Couch, fifth edition)
Fig 1: Basic Communication System (W.Couch, fifth edition)
8/7/2019 Report of Matlab
2/18
[DIGITAL COMMUNICATION SIMULATION USING MATLAB] December 7, 2010
1037089 Page 2
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 intodigital 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. (W.Couch, fifth edition)
The transmitter carrier circuit c
onverts the pr
ocesse
dbaseban
dsignal int
oa
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.
(W.Couch, fifth edition)
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. (W.Couch, fifth edition)
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 anddelivers the estimate of the source information to
the communication system output. (W.Couch, fifth edition)
The communication systems which use atmosphere as the transmission channel,
interference and propagation conditions are strongly dependent on the transmission
frequency. (W.Couch, fifth edition)
8/7/2019 Report of Matlab
3/18
[DIGITAL COMMUNICATION SIMULATION USING MATLAB] December 7, 2010
1037089 Page 3
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 ofup 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 usedfor measurements in the time domain, such as measuring
the transmitter output power of time multiplex systems as a function of time. (Rauscher,
2008)
Spectrum analysis is the process of determining the frequency domain
representation ofa 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 oftime. (unknown, Agilent Spectrum Analysis Basics)
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 ofdifferent frequency and amplitude.
Such a sum is referred to as a Fourier series. (Rauscher, 2008)
(Rauscher, 2008)
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. (unknown, Agilent Spectrum Analysis Basics)
The frequency domain has its measurement strengths. The frequency domain is
better for determining the harmonic content of a signal. Communications people are
8/7/2019 Report of Matlab
4/18
[DIGITAL COMMUNICATION SIMULATION USING MATLAB] December 7, 2010
1037089 Page 4
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 bandof interest and so
not be filtered away. (unknown, Agilent Spectrum Analysis Basics)
A practical quantitative assessment of the higher-order harmonics is not possible in
the Time domain analysis ofa signal. In the frequency domain it is much easier to examine the
short-term stability offrequency and amplitude of a sinusoidal signal compared to the time
domain. (Rauscher, 2008)
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 DFTdecomposes a sequence of values into components ofdifferent 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 DFTofN 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 millionsin practice, the computation time can be reduced by several orders
ofmagnitude in such cases, and the improvement is roughly proportional toN / 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
partiald
iff
erential equatio
ns to
algo
rithmsfo
r quick multiplicatio
nof
large integers.(unknown, Fast Fourier Transform)
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
8/7/2019 Report of Matlab
5/18
[DIGITAL COMMUNICATION SIMULATION USING MATLAB] December 7, 2010
1037089 Page 5
transform we would not be able to compute the Fourier transform with a microprocessor or
DSP based system. (unknown, FFTTutorial)
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. (unknown, FFTTutorial)
The FFTdoes not directly give the spectrum of a signal. The FFT varies dramatically
depending on the number ofpoints (N) of the FFT, and the number ofperiods 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 c
omp
onent.
There
fore, the signal's spectrum sh
ould
be entirely belo
wfs/2 , the
Nyquist frequency. (unknown, FFTTutorial)
The FFToperates by decomposing an N point time domain signal intoN 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. (unknown, Fast Fourier Transform)
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 ofdifferent DFT transform coefficients.
(F.Elliot, 1987)
Cooley-Tukey algorithm is one of the best algorithm used to compute the N point
DFT when N is composite (i.e. when N1N2). In this case it first computes the N1 transforms of
size N2 and then N2 transforms of size N1.
The
fft c
omman
din Matlab is use
dto
evaluate DT
FS and
find
the time-band
wid
thproduct property for discrete-time periodic signals. Since DFTS applies to signals that are
periodic both in time andfrequency, both the duration and bandwidth for the signal within
one period are to be defined. (Veen, 1999)
8/7/2019 Report of Matlab
6/18
[DIGITAL COMMUNICATION SIMULATION USING MATLAB] December 7, 2010
1037089 Page 6
Ifwe 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. (El-Osery, October 27, 2004)
FFTSHI
FT:
FFTSHIFT rearranges the fft output, moving the zerofrequency 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) Ifx is a vector of size n, y is the vector x([n/2+1:n,1:n/2])
3) Ifx 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. (unknown, Scilab
Reference Manual)
In the formula y=fftshift(x)
Input x is a two-dimensional array or a vector, typically the output offft offft2 .
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 ofx
. Likewise, the element z[j+1,k+1]of the output z offft2 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 ofy.
8/7/2019 Report of Matlab
7/18
[DIGITAL COMMUNICATION SIMULATION USING MATLAB] December 7, 2010
1037089 Page 7
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 halfofthe
vector. If the input is a matrix, the first and third quadrants as well as the second andfourth
quadrants are swapped. (unknown, Help for fftshift)
Example: (unknown, Help for fftshift)
>>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")
(unknown, Help for fftshift)
Figure 2: fft andfftshift
It is helpful in visualizing a Fourier transform with the zero-frequency component in
the middle ofthe spectrum.
Consider an another example (El-Osery, October 27, 2004)
8/7/2019 Report of Matlab
8/18
[DIGITAL COMMUNICATION SIMULATION USING MATLAB] December 7, 2010
1037089 Page 8
>> fs=100;
>> 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
(El-Osery, October 27, 2004)
Figure 3: fftshift signal
8/7/2019 Report of Matlab
9/18
[DIGITAL COMMUNICATION SIMULATION USING MATLAB] December 7, 2010
1037089 Page 9
(El-Osery, October 27, 2004)
Figure 4: fftshift with k= -N/2 : N/2-1
(El-Osery, October 27, 2004)
Figure 5: Frequency mapping
8/7/2019 Report of Matlab
10/18
[DIGITAL COMMUNICATION SIMULATION USING MATLAB] December 7, 2010
1037089 Page 10
Task 1: FFT of a Cosine when N=n & N
8/7/2019 Report of Matlab
11/18
[DIGITAL COMMUNICATION SIMULATION USING MATLAB] December 7, 2010
1037089 Page 11
title('when N
8/7/2019 Report of Matlab
12/18
[DIGITAL COMMUNICATION SIMULATION USING MATLAB] December 7, 2010
1037089 Page 12
The second subplot shows the FFTofa 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 ofFFT 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.1fs 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 ofperiods is considered as 3 with the number ofFFT
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;
8/7/2019 Report of Matlab
13/18
[DIGITAL COMMUNICATION SIMULATION USING MATLAB] December 7, 2010
1037089 Page 13
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: FFTofa Cosine with 3, 6, 9 and 12 periods
8/7/2019 Report of Matlab
14/18
[DIGITAL COMMUNICATION SIMULATION USING MATLAB] December 7, 2010
1037089 Page 14
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 of2 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 ofperiods, the Sincs will start looking more and more
like impulses. (unknown, FFTTutorial)
Task 3: Spectrum of an FFT signal using fftshift
Ifwe compute the Fourier transform ofa sine or a cosine function we expect to see
two impulses at the frequency ofthe sine or the cosine. But, that's not what we are seeing.(El-Osery, October 27, 2004)
The FFTdoesnt give directly the spectrum of a signal. The last two experiments
clearly explain that, the FFT varies dramatically with the number ofpoints (N) ofthe FFT,
and the number ofperiods ofthe signal that are represented. There is another problem as
well.
The FFT contains information between 0 andfs , 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 insteadofhaving a spectrum that goes from 0 tofs, it would
be more appropriate to show the spectrum from fs/2 tofs/2 . This can be achieved by
using Matlab's fftshift function as the following code demonstrates. (unknown, FFT
Tutorial)
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);
8/7/2019 Report of Matlab
15/18
[DIGITAL COMMUNICATION SIMULATION USING MATLAB] December 7, 2010
1037089 Page 15
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 ofa Sum ofCosine Signal and Sine Signal
In the above figure the spectrum of the FFTof 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
twoon either side of the zerofrequency and it almost looks like an impulse signal. With the
increase of the length ofthe window, the sinc function almo st looks like an impulse signal.
8/7/2019 Report of Matlab
16/18
[DIGITAL COMMUNICATION SIMULATION USING MATLAB] December 7, 2010
1037089 Page 16
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 todesign 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 DFTof 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 ofsamples in the signal.
It is also studied with the increase in the number ofperiods the sinc pulse turns into
nearly to the shape ofthe 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 ofthe spectrum looking like symmetric signals on either side.
8/7/2019 Report of Matlab
17/18
[DIGITAL COMMUNICATION SIMULATION USING MATLAB] December 7, 2010
1037089 Page 17
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. Retrieveddecember 01, 2010, from
www.google.com.
unknown. (n.d.). Fast Fourier Transform. Retrieveddecember 1st, 2010, from www.wikipedia.com:
http://en.wikipedia.org/wiki/Fast_Fourier_transform
unknown. (n.d.). Fast Fourier Transform. Retrieveddecember 1st, 2010, from www.dspguide.com:
http://www.dspguide.com/ch12/2.htm
unknown. (n.d.). FFTTutorial. ELE 436: Communication Systems , 6.
unknown. (n.d.). Help for fftshift. Retrieveddecember 1st, 2010, from www.google.com:
http://www.mathnium.com/help/fftshift.html
unknown. (n.d.). Scilab Reference Manual. Retrieveddecember 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.
8/7/2019 Report of Matlab
18/18
[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.