Digital Communication Report
Digital Communication Report
ELECTRONIC ENGINEERING
Submitted By:
REMARKS
Signature
Page | 1
INDEX
S.L. EXPERIMENT NAME PAGE REMARKS
NO.
1 Introduction to MATLAB 3 to 5
2 Some Mathematical Functions using MATLAB 6 t0 8
3 Basic Plotting in MATLAB 9 to 15
4 Amplitude Modulation using MATLAB 16 to 17
5 Frequency Modulation 18 to 19
6 Spectrum of amplitude Modulation 20 to 21
7 Spectrum of DSB SSB 22 to 24
8 Spectrum of Frequency Modulation 25 to 26
9 Amplitude Shift keying 27 to 29
10 Quadrature Phase Shift Keying 30 to 31
11 Binary Phase Shift Keying 32 to 33
12 Differential phase Shift Keying 34 to 36
13 PPM, FDM_Dmul 37 to 44
14 Code Division Multiple access 45 to 48
Page | 2
❖ EXPERIMENT NO: 01
❖ OBJECTIVES:
1. Use MATLAB to perform complex arithmetic.
2. Generate and plot signals and complex valued functions.
3. Confidently develop MATLAB M-files and save results of computations from a
MATLAB session.
❖ INTRODUCTION:
The tutorials are independent of the rest of the document. The primarily objective is to help
you learn quickly the first steps. The emphasis here is “learning by doing”. Therefore, the
best way to learn is by trying it yourself. Working through the examples will give you a
feel
for the way that MATLAB operates. In this introduction we will describe how MATLAB
handles simple numerical expressions and mathematical formulas.
The name MATLAB stands for Matrix laboratory. MATLAB was written originally
to provide easy access to matrix software developed by the LINPACK (linear system
package)
and EISPACK (Eigen system package) projects.
❖ Basic features:
As we mentioned earlier, the following tutorial lessons are designed to get you started
quickly in MATLAB. The lessons are intended to make you familiar with the basics of
MATLAB. We urge you to complete the exercises given at the end of each lesson.
❖ Desktop Tools:
▪ Command Window: Use the Command Window to enter variables and run functions and
M-files.
▪ Command History: Statements you enter in the Command Window are logged in the
Command History. In the Command History, you can view previously run statements, and
copy and execute selected statements.
▪ Current Directory Browser: MATLAB file operations use the current directory reference
point. Any file you want to run must be in the current directory or on the search path.
▪ Workspace: The MATLAB workspace consists of the set of variables (named arrays)
built up during a MATLAB session and stored in memory
❖ Basic Commands:
❖ Discussion: Through this experiment we can gain general knowledge about MATLAB and know
how to write a program.
Page | 5
❖ Experiment No: 2
❖ Experiment Name: Mathematical Function Using MATLAB.
❖ Description:
Creating mathematical functions in MATLAB is straightforward. You can define functions using
built-in MATLAB functions or create your own custom functions. Here's a description of how you
can define and use mathematical functions in MATLAB:
❖ Built Functions:
MATLAB provides a wide range of built-in mathematical functions for various operations,
including basic arithmetic, trigonometry, exponentiation, logarithms, and more. These functions
can be used directly in your MATLAB scripts or functions. For example:
❖ MATLAB Code.
% Example of using built-in functions
x = linspace(0, 2*pi, 100); % Generate 100 points between 0 and 2*pi
y = sin(x); % Calculate the sine of each element in x
MATLAB offers a vast array of built-in functions for mathematical operations. These
functions cover a wide range of mathematical domains, including basic arithmetic,
trigonometry, exponential and logarithmic functions, matrix operations, statistical
functions, and more
Here are some examples of commonly used built-in functions:
Basic arithmetic: +, -, *, /, ^
Trigonometric functions: sin, cos, tan, asin, acos, atan
Exponential and logarithmic functions: exp, log, log10
Complex numbers: real, imag, abs, angle
Matrix operations: transpose, inv, det
Statistical functions: mean, median, std, var
You can find a comprehensive list of MATLAB's built-in functions in the official
documentation or by using the help command followed by the function name.
Page | 6
❖ Element – wise Operations:
MATLAB operates on arrays and matrices by default, allowing you to perform element-
wise operations on entire arrays. This means that if you have an array of numbers, you can
apply a mathematical function to each element of the array at once. For example:
❖ MATLAB Code.
% Example of element-wise operations
x = [1, 2, 3, 4];
y = sqrt(x); % Calculate the square root of each element in x
❖ Anonymous Functions:
You can create anonymous functions in MATLAB using the @(arguments) expression
syntax. These functions can be defined on the fly and are useful for simple mathematical
operations or as arguments to other functions. For example:
❖ MATLAB Code.
❖ Custom Function:
MATLAB allows you to define your own custom functions using the function keyword.
You can create separate .m files for your functions and call them from your main script or
other functions. For example, suppose you want to define a function to calculate the area
of a circle:
❖ MATLAB Code.
% Example of custom function definition
function area = circle_area(radius)
area = pi * radius^2;
end
You can then call this function from your main script or other functions:
Page | 7
❖ MATLAB Code.
% Example of calling a custom function
radius = 5;
area = circle_area(radius);
disp(area); % Display the calculated area
❖ Discussion: We have learned through this experiment how mathematical functions work in
MATLAB. Our teacher helped us to do this experiment.
Page | 8
❖ Experiment No: 3
❖ OBJECTIVES:
▪ Define x, by specifying the range of values for the variable x, for which the function is
to be plotted.
▪ Define the function, y = f(x)
▪ Call the plot command, as plot (x, y)
❖ Introduction: Plot (X , Y ) creates a 2-D line plot of the data in Y versus the corresponding
values in X . To plot a set of coordinates connected by line segments, specify X and Y as
vectors of the same length. To plot multiple sets of coordinates on the same set of axes,
specify at least one of X or Y as a matrix.
❖ Fundamentals:
MATLAB works with essentially one kind of object, a rectangular numerical matrix.
Vectors and scalars are referred to as n-by-1 and 1-by-1 matrices respectively. Here is some
basic information on using MATLAB matrix commands.
❖ Entering Matrices
The matrix
132
A= 241
668
can be entered into Matlab by typing the following three lines. Each line ends by pressing
the Return key.
132
A= 241
668
X = 0 : 0.2 : 10
❖ Array Operations
The dimension of one’s vector must match the other vectors in the computation. The
command size(A) returns the dimension of a vector or matrix A.
❖ Basic Overview:
To use the ‘plot’ function in Matlab, you should first make sure that the matrices/vectors
you are trying to use are of equal dimensions. For example, if I wanted to plot vector X = [3 9
27] over time, my vector for time would also need to be a 1x3 vector (i.e. t = [1 2 3]).
Syntax
Labeling Axes
Page | 10
Legends
If you have plotted multiple dependent vectors on the same plot and want to distinguish
them from each other via a legend, the syntax is very similar to the axis labeling above.
It is also possible to set colors for the different vectors and to change the location of the
legend on the figure.
Example:
clear all
X = [3 9 27]; % dependent vectors of interest
Y = [10 8 6];
Z = [4 4 4];
t = [1 2 3]; % independent vector
figure
hold on % allow all vectors to be plotted in same
% figure
plot(t, X, ‘blue’, t, Y, ‘red’, t, Z, ‘green’)
title(‘Plot of Distance over Time’) % title
ylabel(‘Distance (m)’) % label for y axis
xlabel(‘Time (s)’) % label for x axis
legend(‘Trial 1’, ‘Trial 2’, ‘Trial 3’)
legend(‘Location’,‘NorthWest’) % move legend to upper left
Page | 11
❖ Subplots
It can sometimes be useful to display multiple plots on the same figure for comparison.
This can be done using the subplot function, that takes arguments for number of rows of
plots,
number of columns of plots, and plot number currently being plotted:
Example:
clear all
close all
% subplot (nrows,ncols,plot_number)
x=0:.1:2*pi; % x vector from 0 to 2*pi, dx = 0.1
subplot(2,2,1); % plot sine function
plot(x,sin(x));
subplot(2,2,2); % plot cosine function
plot(x,cos(x));
subplot(2,2,3) % plot negative exponential function
plot(x,exp(-x));
subplot(2,2,4); % plot x^3
plot(x, x.^3);
Page | 12
❖ Plotting in 3-D
There are also ways to plot in multiple dimensions in Matlab*. One type of 3-D plot that
may be useful is a surface plot, which requires you to generate some kind of x-y plane and
then apply a 3rd function as the z dimension.
Example:
clear all
close all
[x,y] = meshgrid([-2:.2:2]); % set up 2-D plane
Z = x.*exp(-x.^2-y.^2); % plot 3rd dimension on plane
figure
surf(x,y,Z,gradient(Z)) % surface plot, with gradient(Z)
% determining color distribution
colorbar
% display color scale, can adjust
% location similarly to legend
Page | 13
❖ Making Plots
Matlab provides a variety of functions for displaying data as 2-D or 3-D graphics. For 2-D
graphics, the basic command is:
plot (x1, y1, 'line style', x2, y2, 'line style'...)
This command plots vector x1 versus vector y1, vector x2 versus vector y2, etc. on the same
graph. Other commands for 2-D graphics are: polar, bar, stairs, loglog, semilogx, and
semilogy.
For 3-D graphics, the most commonly used commands are:
plot3(x1, y1, z1, 'line style', x2, y2, z2, 'line style'...)
contour(x,y,Z)
mesh(x,y,Z), surf(x,y,Z)
Page | 14
❖ Plotting Mathematical Functions:
MATLAB also provides powerful plotting capabilities for visualizing mathematical functions.
You can use functions like plot, fplot, surf, etc., to create 2D and 3D plots of mathematical
functions.
❖ MATLAB Code.
% Example of plotting a mathematical function
x = linspace(-2*pi, 2*pi, 100); % Generate 100 points between -2*pi and 2*pi
y = sin(x); % Calculate the sine function values
plot(x, y); % Plot the sine function
title('Plot of y = sin(x)');
xlabel('x');
ylabel('y');
grid on; % Add grid lines to the plot
These are some of the basic techniques for working with mathematical functions in MATLAB.
MATLAB's extensive documentation and online resources provide further guidance and
examples for more advanced operations and applications.
❖ Discussion: We have learned through this experiment how Basic Plating work in
MATLAB. Our teacher helped us to do this experiment.
Page | 15
❖ Experiment No: 4
Page | 16
title('Over Modulated signal(ka.Am=2.5)');
r1= s1.*c;
[b a] = butter(1,0.01);
mr1= filter(b,a,r1);
subplot(4,3,10);
plot(t,mr1);
r2= s2.*c;
[b a] = butter(1,0.01);
mr2= filter(b,a,r2);
subplot(4,3,11);
plot(t,mr2);
r3= s3.*c;
[b a] = butter(1,0.01);
mr3= filter(b,a,r3);
subplot(4,3,12);
plot(t,mr3);
❖ Result:
Much like amplitude modulation, frequency modulation also has a similar approach, where
a carrier signal is modulated by the input signal. However, in the case of FM, the amplitude
of the modulated signal is kept, or it remains constant.
❖ Result:
Page | 19
❖ Experiment No: 6
❖ Description: The spectrum of an amplitude modulated is related to the sidebands that are
generated and hence to the bandwidth. The bandwidth of an amplitude modulated signal is
of importance for many reasons. The amplitude modulation, AM bandwidth is important
when designing filters to receive the signals, determining the channel spacing, and for a
number of other reasons.
The spectrum and bandwidth of an amplitude modulated signal are determined by the
sidebands that are generated when amplitude modulation is applied to the carrier.
It can be seen that if the top frequency that is modulated onto the carrier is 6 kHz, then the
top spectra will extend to 6 kHz above and below the signal. In other words, the bandwidth
occupied by the AM signal is twice the maximum frequency of the signal that is used to
modulated the carrier, i.e., it is twice the bandwidth of the audio signal to be carried.
Page | 20
subplot(3,1,2); plot(frqdouble, zdouble);
title('Spectrum of double-sideband signal');
subplot(3,1,3); plot(frqsingle, zsingle);
title('Spectrum of single-sideband signal');
❖ Result:
Page | 21
❖ Experiment No: 7
❖ Description:
DSB: Double-sideband suppressed-carrier transmission (DSB-SC) is transmission in
which frequencies produced by amplitude modulation (AM) are symmetrically spaced
above and below the carrier frequency and the carrier level is reduced to the lowest
practical level, ideally being completely suppressed.
In the DSB-SC modulation, unlike in AM, the wave carrier is not transmitted; thus, much
of the power is distributed between the side bands, which implies an increase of the cover
in DSB-SC, compared to AM, for the same power use.
DSB-SC transmission is a special case of double-sideband reduced carrier transmission. It
is used for radio data systems. This mode is frequently used in amateur radio voice
communications, especially on high-frequency bands
SSB: single-sideband suppressed-carrier modulation (SSB-SC) is a type
of modulation used to transmit information, such as an audio signal, by radio waves. A
refinement of amplitude modulation, it uses transmitter power and bandwidth more
efficiently. Amplitude modulation produces an output signal the bandwidth of which is
twice the maximum frequency of the original baseband signal. Single-sideband modulation
avoids this bandwidth increase, and the power wasted on a carrier, at the cost of increased
device complexity and more difficult tuning at the receiver.
%plot
subplot(4,1,1),plot(t,m);
xlabel('time');
ylabel('amplitude');
Page | 22
legend('Message signal m(t)');
title('message');
subplot(4,1,2),plot(t,c);
xlabel('time');
ylabel('amplitude');
legend('Carrier signal c(t)');
title('carrier');
subplot(4,1,3),plot(t,mod);
xlabel('time');
ylabel('amplitude');
legend('Amplitude modulated signal s(t)');
title('mod');
%fm signal
b=(fc-fm)/fm;
modfm=ac.*cos(2*pi*fc.*t + b*sin(2*pi*fm.*t));
subplot(4,1,4)
plot(t,modfm);
xlabel('time---(sec)');
ylabel('amp');
legend('Frequency modulated signal s(t)');
title('FM signal')
………….
Page | 23
❖ Result:
❖ Discussion: Through this experiment we learned how Expect Tram of Spectrum of DSB
SSB works and how to program it in MATLAB software. Our teacher helped us to run my
program without any problems.
Page | 24
❖ Experiment No: 8
Page | 25
❖ MATLAB Source Code:
%program of spectrum analyzer and analysis of Fm
❖ Result:
Page | 26
❖ Experiment No: 9
%ASK Modulation
clc;
clear all;
close all;
%GENERATE CARRIER SIGNAL
Tb=1; fc=10;
t=0:Tb/100:1;
c=sqrt(2/Tb)*sin(2*pi*fc*t);
%generate message signal
N=8;
m=rand(1,N);
t1=0;t2=Tb
for i=1:N
t=[t1:.01:t2]
if m(i)>0.5
m(i)=1;
m_s=ones(1,length(t));
else
m(i)=0;
m_s=zeros(1,length(t));
end
message(i,:)=m_s;
%product of carrier and message
ask_sig(i,:)=c.*m_s;
t1=t1+(Tb+.01);
t2=t2+(Tb+.01);
Page | 27
%plot the message and ASK signal
subplot(5,1,2);axis([0 N -2 2]);plot(t,message(i,:),'r');
title('message signal');xlabel('t--->');ylabel('m(t)');grid on
hold on
subplot(5,1,4);plot(t,ask_sig(i,:));
title('ASK signal');xlabel('t--->');ylabel('s(t)');grid on
hold on
end
hold off
%Plot the carrier signal and input binary data
subplot(5,1,3);plot(t,c);
title('carrier signal');xlabel('t--->');ylabel('c(t)');grid on
subplot(5,1,1);stem(m);
title('binary data bits');xlabel('n--->');ylabel('b(n)');grid on
% ASK Demodulation
t1=0;t2=Tb
for i=1:N
t=[t1:Tb/100:t2]
%correlator
x=sum(c.*ask_sig(i,:));
%decision device
if x>0
demod(i)=1;
else
demod(i)=0;
end
t1=t1+(Tb+.01);
t2=t2+(Tb+.01);
end
%plot demodulated binary data bits
subplot(5,1,5);stem(demod);
title('ASK demodulated signal'); xlabel('n--->');ylabel('b(n)');grid on
Page | 28
❖ Result:
❖ Discussion: Through this experiment we learned how Expect Tram of Amplitude Shift
keying. Works and how to program it in MATLAB software. Our teacher helped us to run
my program without any problems
Page | 29
❖ Experiment No: 10
Page | 30
❖ Result:
❖ Discussion: Through this experiment we learned how Expect Tram of Quadrature Phase
Shift Keying. Works and how to program it in MATLAB software. Our teacher helped us
to run my program without any problems
Page | 31
❖ Experiment No: 11
❖ Description: Binary Phase Shift Keying (BPSK) is a widely used modulation technique
in digital communication systems for transmitting binary data over a communication
channel. It is known for its simplicity and effectiveness, making it a popular choice in
applications where the communication channel is susceptible to noise and interference.
Binary Phase Shift Keying (BPSK) is a modulation technique employed in
communication systems to transmit information via a communication channel. In BPSK
the carrier signal is modified by altering its phase by 180 degrees, for each symbol. A
phase shift of 180 degrees denotes a binary 0 while no phase shift represents a binary 1.
The BPSKs modulation process is straightforward and efficient making it suitable for
scenarios where the communication channel suffers from noise and interference.
BPSK holds significance in communication systems like Wi-Fi, Bluetooth and satellite
communication. Its simplicity and robustness make it an excellent choice for applications
where the quality of the communication channel isn’t optimal. Using a basic phase shift
to convey symbols BPSK can reliably transmit data, over channels guaranteeing
dependable communication.
❖ Result:
❖ Discussion: Through this experiment we learned how Expect Tram of Binary Phase Shift
Keying. Works and how to program it in MATLAB software. Our teacher helped us to run
my program without any problems
Page | 33
❖ Experiment No: 12
rng default
M = 6; % Alphabet size
rxSig = txSig*exp(2i*pi*rand());
dataOut = dpskdemod(rxSig,M);
errs = symerr(dataIn,dataOut)
errs = symerr(dataIn(2:end),dataIn(2:end))
figure
subplot(2,2,1)
Page | 34
plot(dataIn)
title('DATA')
subplot(2,2,2)
plot(txSig)
title('DPSK SIGNAL')
subplot(2,2,3)
plot(rxSig)
title('Received DPSK')
subplot(2,2,4)
plot(dataOut)title('DATA RECEIVED')
Page | 35
❖ Result:
❖ Discussion: Through this experiment we learned how Expect Tram of Differential phase
Shift Keying. Works and how to program it in MATLAB software. Our teacher helped us
to run my program without any problems
Page | 36
❖ Experiment No: 13
❖ Description:
PPM: This is a way of expressing very dilute concentrations of substances. Just as per
cent means out of a hundred, so parts per million or ppm means out of a million.
Usually describes the concentration of something in water or soil. One ppm is
equivalent to 1 milligram of something per liter of water (mg/l) or 1 milligram of
something per kilogram soil (mg/kg).
To accommodate the successful transmission of multiple signals over a single line, FDM
separates assigned bands by strips of unused frequencies called guard bands. This prevents
overlapping between signal frequencies over a shared medium.
A signal is generated and modulated by a sending device and is carried over the separated
bands. The modulated signals are combined using a multiplexer (mux) and transmitted over
the communication channel. At the receiving end, the combined signal goes through a
demultiplexer (demux) to extract the individual signals.
Page | 37
❖ MATLAB Source Code:
Page | 38
xlabel('freqency');
ylabel('magnitude');
subplot(4,1,4);
plot(z2);
title('Spectrum of signal 2');
xlabel('freqency');
ylabel('magnitude');
% freqency multiplexing
z=z1+z2;
figure;
plot(z);
title('frequency multiplexed signals');
figure;
% freqency demultiplexing
f1=[ones(10,1); zeros(182,1);ones(10,1)];%applying filter for signal 1
dz1=z.*f1;
d1 = ifft(dz1);
subplot(2,1,1)
plot(t*100,d1);
f2=[zeros(10,1); ones(182,1);zeros(10,1)];% applying filter for signal 2
dz2=z.*f2;
d2 = ifft(dz2);
title('recovered signal 1');
xlabel('time');
ylabel('amplitude');
subplot(2,1,2)
plot(t*100,d2);
title('recovered signal 2');
xlabel('time');
ylabel('amplitude');
Page | 39
❖ Result:
Page | 40
Page | 41
Page | 42
❖ MATLAB Source Code:
fc=100; fs=1000;
f1=80; f2=300 ;
t=0:1/fs:((2/f1)-(1/fs));
x1=0.4*cos(2*pi*f1*t)+0.5;
%x2=0.2*(cos(2*pi*f1*t)+cos(2*pi*f2*t))+0.5 ;
subplot(4,2,1);
plot(x1);
title('original msg signal');
y1=modulate(x1,fc,fs,'ppm');subplot(4,2,2);
plot(y1)
axis([0 50 -0.2 1.2]);
title('ppm one of f1,fc=1000,f1=80 ');
fx1=abs(fft(y1,1024)) ;
fx1=[fx1(512:1024) fx1(1:513)];
f=[(511*fs/1024):(fs/1024):(512*fs/1024)];
subplot(4,2,3);
plot(fx1);
title('freq des ppm signal tone,fc=1000');
x1_recov = demod(y1,fc,fs,'ppm');
subplot(4,2,4);
plot(x1_recov);
title('time domain recovered signal');
Page | 43
❖ Result:
❖ Discussion: Through this experiment we learned how Expect Tram of PPM FDM_Dmul.
Works and how to program it in MATLAB software. Our teacher helped us to run my
program without any problems
Page | 44
❖ Experiment No: 14
In CDMA, all signals occupy the same frequency bandwidth and are transmitted
simultaneously in time, but the different signals are distinguished from one another at the
receiver by the specific spreading codes or frequency hopping pattern. Spread
spectrum multiple access (SSMA), which is the most popular CDMA, is achieved by two
techniques: direct sequence (DS) modulation and frequency hopping (FH) modulation. In
DS, the modulated signal is multiplied by pseudorandom noise (PN) codes with a chip rate
of Rc, which is much larger than an information bit rate of Rb. The resulting signal has
wider frequency bandwidth than the original modulated signal.
while i<9
if b1(i)== 0
b1(i)=1;
elseif b1(i)== 1
b1(i)= -1;
else
break
end
i=i+1;
end
fprintf('voltage converted spread signal of user1\n');
disp(b1)
i=1;
while i<9
Page | 46
if b2(i)== 0
b2(i)=1;
elseif b2(i)== 1
b2(i)= -1;
else
break
end
i=i+1;
end
fprintf('voltage converted spread signal of user2\n');
disp(b2)
i=1;
while i<9
if b3(i)== 0
b3(i)=1;
elseif b3(i)== 1
b3(i)= -1;
else
break
end
i=i+1;
end
fprintf('voltage converted spread signal of user3\n');
disp(b3)
b= b1+b2+b3
subplot(4,1,4); stem(t,b)
m = b.*b1
Page | 47
sum11 = m(1)+m(2)+m(3)+m(4);ave11 = sum11/4;
sum12 = m(5)+m(6)+m(7)+m(8);ave12 = sum12/4;
fprintf('%f %f\n',ave11,ave12);
❖ Result:
❖ Discussion: Through this experiment we learned how Expect Tram of Code Division
Multiple access. Works and how to program it in MATLAB software. Our teacher helped
us to run my program without any problems
Page | 48