0% found this document useful (0 votes)
2 views

Adcs Lab Report

The document is a lab report for Analog and Digital Communication experiments by Raj Kumar, detailing the use of MATLAB for various numerical computations and data visualizations. It includes a list of MATLAB commands with their syntax and descriptions, as well as two specific experiments involving the generation of sequences such as unit sample, step, ramp, sine, and cosine waves. The report emphasizes MATLAB's applications in engineering and scientific fields, highlighting its ease of use and powerful capabilities.

Uploaded by

raj.kumar1262002
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Adcs Lab Report

The document is a lab report for Analog and Digital Communication experiments by Raj Kumar, detailing the use of MATLAB for various numerical computations and data visualizations. It includes a list of MATLAB commands with their syntax and descriptions, as well as two specific experiments involving the generation of sequences such as unit sample, step, ramp, sine, and cosine waves. The report emphasizes MATLAB's applications in engineering and scientific fields, highlighting its ease of use and powerful capabilities.

Uploaded by

raj.kumar1262002
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 29

LAB REPORT

ANALOG AND DIGITAL COMMUNICATION


LAB EXPERIMENTS

NAME: - RAJ KUMAR


BRANCH: - ELECTRICAL AND ELECTRONICS
REGISTRATION NUMBER: - 21110111026
SUBJECT: - ANALOG AND DIGITAL
COMMUNICATION LAB EXPERIMENTS
(A.D.C]
INDEX
S.NO. NAME OF DATE OF DATE OF REMARKS SIGNATURE
EXPERIMENT EXPERIMENT SUBMISSION
MATLAB, which stands for MATrix LABoratory, is a state-of-the-art mathema cal so ware package,
which is used extensively in both academia and industry. It is an interac ve program for numerical
computa on and data visualiza on, which along with its programming capabili es provides a very
useful tool for almost all areas of science and engineering. Unlike other mathema cal packages, such
as MAPLE or MATHEMATICA, MATLAB cannot perform symbolic manipula ons without the use of
addi onal Toolboxes. It remains however, one of the leading so ware packages for numerical
computa on. MATLAB is interac ve so ware which has been used recently in various areas of
engineering and scien fic applica ons. It is not a computer language in the normal sense but it does
most of the work of a computer language. Wri ng a computer code is not a straigh orward job,
typically boring and me consuming for beginners. One a rac ve aspect of MATLAB is that it is
rela vely easy to learn. It is wri en on an intui ve basis and it does not require in-depth knowledge
of opera onal principles of computer programming like compiling and linking in most other
programming languages. This could be regarded as a disadvantage since it prevents users from
understanding the basic principles in computer programming. The interac ve mode of MATLAB may
reduce computa onal speed in some applica ons.The power of MATLAB is represented by the length
and simplicity of the code. For example, one page of MATLAB code may be equivalent to many pages
of othercomputer language source codes. Numerical calcula on in MATLAB uses collec onsof well-
wri en scien fic/mathema cal subrou nes such as LINPACK and EISPACK. MATLAB provides
Graphical User Interface (GUI) as well as three-dimensional graphical anima on.In general, MATLAB
is a useful tool for vector and matrix manipula ons.Since the majority of the engineering systems are
represented by matrix and vector equa ons, we can relieve our workload to a significant extent by
using MATLAB.The finite element method is a well-defined candidate for which MATLAB can be very
useful as a solu on tool. Matrix and vector manipula ons are essen al parts in the method. MATLAB
provides a help menu so that we can type the help command when we need help to figure out a
command. The help u lity is quite convenient for both beginners and experts. Applica on of MATLAB
There is a wide range of areas where MATLAB tools are applied. These areas include mathema cs,
physics, chemistry and chemical engineering, mechanical engineering, biological (molecular biology)
and medical sciences, communica on and control systems, digital signal, image and video
processing,

Applica on of MATLAB There is a wide range of areas where MATLAB tools are applied. These areas
include mathema cs, physics, chemistry and chemical engineering, mechanical engineering,
biological (molecular biology) and medical sciences, communica on and control systems, digital
signal, image and video processing,

system modeling and simula on. Many interes ng problems have been included throughout the
book, and its contents will be beneficial for students and professionals in wide areas of interest.
S.NO. COMMAND SYNTAX/CODE

1 clc clc
clc clears all input and output from the Command Window
display, giving you a "clean screen."

2 clear all clear all ;


clear all removes all variables from the workspace,
releasing them from system memory

3 close all close all;


close all deletes all figures whose handles are not hidden.

for for index = values


4 program statements
:
end
for index=values, program statements, end repeatedly
executes one or more MATLAB statements in a loop. values
has one of the following forms
1)initval:endval increments the index variable from initval
to endval by 1, and repeats execu on of program
statements un l index is greater than endval.
2) initval:step:endval increments index by the value step on
each itera on, or decrements when step is nega ve.
5 help

help functionName

Displays information and documentation about a


function
6 Ismac

ismac Checks if MATLAB is running on a macOS platform

7 system system('Command')
Executes a system Command from within MATLAB

8 isvarname isvarname('variableName')
Checks if a string is a valid MATLAB variable name

9 isunix isunix
Checks if MATLAB is running on a UNIX-like platform

10 quit Quit
Terminates the MATLAB session

11 while while expression


program statements
:
end
while expression, program statements, end repeatedly executes one
or more MATLAB program statements in a loop, con nuing un l
expression no longer holds true or un l MATLAB encounters a break,
or return instruc on, thus forcing an immediate exit of the loop
code. If MATLAB encounters a con nue statement in the loop code, it
interrupts execu on of the loop code at the loca on of the con nue
statement, and begins another itera on of the loop at the while
expression statement.
12 If if expression,
statements
end
if expression, statements, end evaluates expression and, if the
evalua on yields logical 1 (true) or a nonzero result, executes one or
more MATLAB commands denoted here as statements.
The if func on can be used alone or with the else and elseif
func ons. When using elseif and/or else within an if statement, the
general form of the statement is
if expression1
statements1
else
if expression2
statements2
else
statements3
13 input evalResponse = input(‘prompt’)

evalResponse = input(prompt) displays the prompt string on the screen,


waits for input from the keyboard, evaluates any expressions in the
input, and returns the value in evalResponse.

14 disp disp(X)

disp(X) displays an array, without prin ng the array name. If X contains a


text string, the string is displayed. Another way to display an array on
the screen is to type its name, but this prints a leading "X=," which is
not always desirable. Note that disp does not display empty arrays.
15 plot plot(Y)
plot(X,Y)
plot(Y) plots the columns of Y versus the index of each value when Y is a
real number.Gives a con nuous plot.
plot(X,Y) plots Y vs X

16 stem stem(Y)
stem(X,Y)
stem(Y) plots the data sequence Y as stems that extend from equally
spaced and automa cally generated values along the x-axis. When Y is a
matrix, stem plots all elements in a row against the same x value.
stem(X,Y) plots X versus the columns of Y. X and Y must be vectors or
matrices of the same size. Addi onally, X can be a row or a column
vector and Y a matrix with length(X) rows.
Gives a discrete plot
17 subplot subplot(m,n,p) or subplot(mnp)

subplot(m,n,p) or subplot(mnp) breaks the figure window into an m-by-


n matrix of small axes, selects the pth axes object for the current plot,
and returns the axes handle. The axes are counted along the top row of
the figure window, then the second row, etc.
18 Xlabel xlabel('string')
Ylabel ylabel('string')
zlabel zlabel('string')

Each axes graphics object can have one label for the x-, y-, and z-axis.
The label appears beneath its respec ve axis in a two-dimensional plot
and to the side or beneath the axis in a three-dimensional plot.

xlabel('string') labels the x-axis of the current axes. ylabel(...) and


zlabel(...) label the y-axis and z-axis, respec vely, of the current axes.
19 legend legend('string1','string2',...)
legend places a legend on various types of graphs (line plots, bar
graphs, pie charts, etc.). For each line plo ed, the legend shows
a sample of the line type, marker symbol, and color beside the
text label you specify. When plo ng filled areas (patch or
surface objects), the legend contains a sample of the face color
next to the text label. The font size and font name for the legend
strings match the axes FontSize and FontName proper es.
legend('string1','string2',...) displays a legend in the current axes
using the specified strings to label each set of data.
20 max C = max(A)
C = max(A,B)
C = max(A) returns the largest elements along different
dimensions of an array. If A is a vector, max(A) returns the
largest element in A.

C = max(A,B) returns an array the same size as A and B with the


largest elements taken from A or B. The dimensions of A and B
must match, or they may be scalar.
21 min C = min(A)
C = min(A,B)
C = min(A) returns the smallest elements along different
dimensions of an array. If A is a vector, min(A) returns the
smallest element in A. C = min(A,B) returns an array the same
size as A and B with the smallest elements taken from A or B.
The dimensions of A and B must match, or they may be scalar.
22 length
numberOfElements = length(array)
numberOfElements = length(array) finds the number of
elements along the largest dimension of an array. array is an
array of any MATLAB data type and any valid dimensions.
numberOfElements is a whole number of the MATLAB double
class.
23 sqrt B = sqrt(X)
B = sqrt(X) returns the square root of each element of the array
X. For the elements of X that are nega ve or complex, sqrt(X)
produces complex results

24 exp Y = exp(X)
The exp func on is an elementary func on that operates
element-wise on arrays. Its domain includes complex numbers.
Y = exp(X) returns the exponen al for each element of X.
25 abs abs(X)

abs(X) returns an array Y such that each element of Y is the


absolute value of the corresponding element of X. If X is
complex, abs(X) returns the complex modulus (magnitude),
which is the same as sqrt(real(X).^2 + imag(X).^2)
tle tle('string')
Each axes graphics object can have one tle. The tle is located at the
top and in the center of the axes.
26
EXPERIMENT NO: - 1
Object: Write a MATLAB program to generate the following sequence.

A. Unit Sample Sequence [(n)].


B. Unit Step Sequence [ (n) (n-m) ].
C. Unit Ramp Sequence
D. Sine Wave
E. Cosine Wave

Theory:

A: Unit Sample Sequence [ (n)].

Defini on-

The Dirac delta func on, or δ func on, is (informally) a generalized func on on the real number line
that is zero everywhere except at zero, with an integral of one over the en re real line. The delta
func on is some mes thought of as an infinitely high, infinitely thin spike at the origin, with total
area one under the spike
∞, 𝑥 = 0
(n) =
0, 𝑥 ≠ 0

and which is also constrained to sa sfy the iden ty

B: Unit Step
sequence [μ(n)]
Defina on-
The unit step func on is just a piecewise func on with a jump discon nuity at t = a.
Recall from calculus that a jump discon nuity is an x-value for which the limit doesn’t
exist. Then general form ofthe unit step func on is given below.

Mu(t-a) = 0, t<a

=M, t>a

The M in the func on represents the height of the jump


and a is the number of units shi ed to the right.
C: Unit Ramp Sequence
Defini on--The ramp func on may be defined analy cally in several ways. Possible defini ons are:

D:Sine
Wave
Defini o
n- y=
sinx
E:Cosine

Wave

Defini on - y= cos x

Source code:
clc;
clear all;
close all;
m=input('enter the value of m');
n=-10:10;
for i=1:length(n)
if n(i)==0
y(i)=1;
else
y(i)=0;
end
end
subplot(2,3,1)
stem(n,y)
xlabel('n')
ylabel('y')
title('unit sample sequence');
for i=1:length(n)
if n(i)<0||n(i)>m
y(i)=0;
else
y(i)=1;
end
end
subplot(2,3,2)
stem(n,y)
xlabel('n')
ylabel('y')
title('unit stem sequence u(n)-u(n-M)');
for i=1:length(n)
if n(i)<0
y(i)=0;
else
y(i)=n(i);
end
end
subplot(2,3,3)
stem(n,y)
xlabel('n')
ylabel('y')
title('Ramp sequence');
t=-pi/2:0.1:pi/2;
y=sin(2*pi*t);
subplot(2,3,4)
stem(t,y)
xlabel('t');
ylabel('y');
title('sine')
t=-pi/2:0.1:pi/2;
y=cos(2*pi*t);
subplot(2,3,5)
stem(t,y)
xlabel('t');
ylabel('y');
title('cosine')
EXPERIMENT NO: - 2
OBJECT 2: WRITE A MATLAB PROGRAM TO GENERATE AN EXPONENTIAL
SEQUENCE.
X(n) = (a)n for (i) 0≤a≤1 (ii) -1≤a≤0 (iii)a≤-1 (iv)a>1
THEORY:
EXPONENTIAL SIGNAL IS GIVEN BY
X(n) = (a)n
DEPENDING UPON THE VALUE OF ‘a’ THE EXPONENTIAL CURVE
CAN BE
SOURCE CODE:

clc;
close all;
clear all;
a1=input('enter the value of a such that
0<=a<=1'); a2=input('enter the value of a such
that -1<=a<=0'); a3=input('enter the value of a
such that a<=-1'); a4=input('enter the value of a
such that a>1');
for n=1:20
x1(n)=(a1)^n;
x2(n)=(a2)^n;
x3(n)=(a3)^n;
x4(n)=(a4)^n;
end
subplot(2,2,1)
stem(x1);
xlabel('-----n--->');
ylabel(' x1(n)-->');
title('plot of x1');
subplot(2,2,2)
stem(x2);
xlabel('-----n >');
ylabel('-----x2(n)-->');
title('plot of x2');
subplot(2,2,3)
stem(x3);
xlabel('-----n >');
ylabel('-----x3(n)-->');
title('plot of x3');
subplot(2,2,4)
stem(x4);
xlabel('-----n >');
ylabel('-----x4(n)-->');
title('plot of x4');

enter the value of a such that 0<=a<=10.9


enter the value of a such that -1<=a<=0-0.9
enter the value of a such that a<=-1-2
enter the value of a such that a>12

plot of x1 plot of x2
1 1

0.8
0.5
-----x2(n)-->
x1(n)-->

0.6
0
0.4

-0.5
0.2

0 -1
0 5 10 15 20 0 5 10 15 20
-----n---> -----n>
6 plot of x3 5 plot of x4
10 10
1.5 12

1 10

8
-----x3(n)-->

-----x4(n)-->

0.5
6
0
4
-0.5 2

-1 0
0 5 10 15 20 0 5 10 15 20
-----n> -----n>
EXPERIMENT NO.: -3
OBJECT: WRITE A MATLAB PROGRAM TO GENERATE THE SIGNAL
S(n) = 2*n*(0.8^n) CORRUPTED BY THE NOISE d(n)
RESULTING THE SIGNAL X(n).
X(n) = s(n) + d(n)
ALSO DOWN SAMPLE THE CORRUPTED SIGNAL

THEORY: THE SIGNAL S(n) IS THE PRODUCT OF TWO FUNCTIONS.


THE TWO FUNCTIONS ARE NAMELY THE RAMP FUNCTION
‘n’ AND THE EXPONENT POWER FUNCTION ‘(0.8)^n’. THE
SIGNAL IS CORRUPTED BY NOISE d(n) WHICH IS A
RANDOM NOISE. RANDOM NOISE IS DEFINED AS NOISE
CONSISTING OF LARGE NUMBER OF TRANSIENT
DISTURBANES WITH A STATISTICALLY IS THE PROCESS OF
REDUCING THE SAMPLING RATE OF A SIGNAL.
SOURCE CODE:
clc;
clear all;
close all;
d=rand(1,10);
for n=1:10
s(n)=2.*n.*((.8)^n);
x1(n)=s(n)+d(n);
end
subplot(2,2,1);
stem(d);
xlabel('------ n >');
ylabel('----- d >');
title('random noise d(n)');
subplot(2,2,2);
stem(s);
xlabel('------ n >');
ylabel('----- s(n) >');
title('signal s(n)');
subplot(2,2,3);
stem(x1);
xlabel('------ n >');
ylabel('----- x1 >');
title('signal s(n)corrupted by noise d(n)');
n=1:5;
for i=1:5
x2(i)=x1((2*i-1));
end
subplot(2,2,4)
stem(n,x2);
xlabel('------ n >');
ylabel('----- x2 >');
title('corrupted signal downsample by 2');

random noise d(n) signal s(n)


1 4

0.8
3
----- s(n)>

0.6
----- d>

2
0.4

1
0.2

0 0
0 2 4 6 8 10 0 2 4 6 8 10
------ n> ------ n>

signal s(n)corrupted by noise d(n) corrupted signal downsample by 2


5 5

4 4
----- x1>

----- x2>

3 3

2 2

1 1

0 0
0 2 4 6 8 10 1 2 3 4 5
------ n> ------ n>
EXPERIMENT NO.: - 4
OBJECT: GENERATE A GAUSSIAN NUMBER WITH MEAN = 20 AND
VARIANCE = 40. ALSO PLOT THE PDF OF GENERATED NUMBER

THEORY: THE NORMAL DISTRIBUTIONS ARE A VERY IMPORTANT CLASS OF


STATISTICAL DISTRIBUTIONS. A NORMAL DISTRIBUTIONS ARE
SYMMWTRIC AND HAVE BELL- SHAPED DENSITY CURVES WITH A
SINGLE PEAK.
TO SPEAK SPECIFICALLY OF ANY NORMAL DISTRIBUTION, TWO
QUANTITIES HAVE TO BE SPECIFIED: THE MEAN µ, WHERE THE
PEAK OF THE DENSITY OCCURS, AND THE STANDARD
DEVIATION , WHICH INDICATES THE SPREAD OR
GIRTH OF THE BELL CURVE.
IN PROBABILITY THEORY, THE NORMAL (OR GAUSSIAN)
DISTRIBUTION IS A CONTINUOUS PROBABILITY DISTRIBUTION,
DEFINED BY THE FORMULA

THE PARAMETER μ IN THIS FORMULA IS THE MEAN OR


EXPECTATION OF THE DISTRIBUTION (AND ALSO ITS MEDIAN AND
MODE). THE PARAMETER σ IS THE STANDARD DEVIATION; ITS
VARIANCE IS THEREFORE σ 2. A RANDOM VARIABLE WITH A
GAUSSIAN DISTRIBUTION IS SAID TO BE NORMALLY DISTRIBUTED
AND IS CALLED AND IS CALLED A NORMAL DEVIATE.
SOURCE CODE:
clear all;
close all;
clc;
mean=20;
var=40;
r=normrnd(20,sqrt(40),1,200);
for i=1:200
y(i)=(1/sqrt(2*pi*var))*exp((-(r(i)-
mean)^2)/(2*var));
end
stem(r,y);
xlabel('----x >');
ylabel('----y(x) >');
title('pdf of generated gaussian no.');
pdf of generated gaussian no.
0.07

0.06

0.05

0.04
----y(x)>

0.03

0.02

0.01

0
0 5 10 15 20 25 30 35 40
----x>
EXPERIMENT NO.: - 5
AIM: TO STUDY AMPLITUDE MODULATION AND
DEMODULATION USING BOTH MATALB
CODE AND SIMULINK

THEORY: A continuous-wave goes on continuously without any


intervals and it is the baseband message signal, which contains
the information. This wave has to be modulated.

According to the standard definition, “The amplitude of the carrier


signal varies in accordance with the instantaneous amplitude of
the modulating signal.” Which means, the amplitude of the carrier
signal containing no information varies as per the amplitude of
the signal containing information, at each instant. This can be
well explained by the following figures.
The first figure shows the modulating wave, which is the message
signal. The next one is the carrier wave, which is a high
frequency signal and contains no information. While, the last one
is the resultant modulated wave.

It can be observed that the positive and negative peaks of the


carrier wave, are interconnected with an imaginary line. This line
helps recreating the exact shape of the modulating signal. This
imaginary line on the carrier wave is called as Envelope. It is the
same as that of the message signal.
Mathematical Expressions

Following are the mathematical expressions for these waves.

Time-domain Representation of the Waves

Let the modulating signal be,

m(t)=Amcos(2πfmt)

and the carrier signal be,

c(t)=Accos(2πfct)

Where,

Am and Ac are the amplitude of the modulating signal and the


carrier signal respectively.

fm and fc are the frequency of the modulating signal and the


carrier signal respectively.

Then, the equation of Amplitude Modulated wave will be

s(t)=[Ac+Amcos(2πfmt)]cos(2πfct) (Equation 1)

AMPLITUDE DEMODULATION
The process of extracting an original message signal from the
modulated wave is known as detection or demodulation. The
circuit, which demodulates the modulated wave is known as
the demodulator. The following demodulators (detectors) are used
for demodulating AM wave.

 Square Law Demodulator


 Envelope Detector
Square Law Demodulator

Square law demodulator is used to demodulate low level AM


wave. Following is the block diagram of thesquare law
demodulator.
REQUIREMENT: -
MATALB
PROGRAM: -
SOURCE CODE: -
clc
clear all
t=linspace(0,0.02,10000);
fc=10000;
fm=200;
fs=40000;
Am=5;
Ac=10;
m=Am/Ac
wc=2*pi*fc*t;
wm=2*pi*fm*t;
ec=Ac*sin(wc);
em=Am*sin(wm);
y=Ac*(1+m*cos(wm)).*cos(wc);
z=y.*ec;

m=

0.5000
SIMULINK
EXPERIMENT NO.: - 6
OBJECT: - TO STUDY FREQUENCE MODULATION AND
DEMODULATION
THEORY: - Frequency Modulation is a modulation in which the frequency of the carrier
wave is altered in accordance with the instantaneous amplitude of the modulating signal,
keeping phase and amplitude constant. Modification of carrier wave frequency is performed
for the purpose of sending data or information over small distances.

FM signals can be generated either by using direct frequency modulation, which is


achieved by inputting a message directly into a voltage-controlled oscillator, or by
using indirect frequency modulation, which is achieved by integrating a message
signal to generate a phase-modulated signal, which is then used to modulate a
crystal-controlled oscillator, the result of which is transmitted through a frequency
multiplier to produce an FM signal.

Frequency Modulation use cases include FM radio broadcasting, magnetic tape-


recording systems, monitoring newborns for seizures via EEG, radar, seismic
prospecting, sound synthesis, telemetry, two-way radio systems, and video-
transmission systems.

FREQUENCY DEMODULATION
Demodulation is the act of extracting the original information- bearing signal from a
modulated carrier wave or the process of separating the original information or signal
from the modulated carrier wave. This process is used in the receivers to recover the
original signal coming from the sender end n modulating form. We can say that its
function is opposite to that of modulation process. There are several ways to
demodulation depending upon how parameters of the base-band signal are
transmitted in the carrier signal, such as amplitude, frequency or phase. For a signal
modulated with a linear modulation, like Amplitude modulation we can use a
synchronous detector, for a signal modulated with an angular modulation use a
Frequency demodulator.

REQUIREMENT: -
MATALB
PROGRAM: -
SOURCE CODE
clc
clear all
Fs = 8000;
Fc = 100;
t = linspace(0,1,10000);
x = sin(2*pi*10*t)
dev = 50;
y = fmmod(x,Fc,Fs,dev);
z = fmdemod(y,Fc,Fs,dev);
subplot(411),plot(t,x)
xlabel('time(sec)');
ylabel('amplitude in volts(V)');
title('MODULATING SIGNAL');
subplot(412),plot(t,sin(2*pi*Fc*t))
xlabel('time(sec)');
ylabel('amplitude in volts(V)');
title('CARRIER SIGNAL');
subplot(413),plot(t,y)
xlabel('time(sec)');
ylabel('amplitude in volts(V)');
title('FREQUENCY MODULATED SIGNAL');
subplot(414),plot(t,z)
xlabel('time(sec)');
ylabel('amplitude in volts(V)');
title('DEMODULATED SIGNAL')

-0.0628 -0.0565 -0.0502 -0.0440 -0.0377 -0.0314 -0.0251

Columns 9997 through 10000

You might also like