0% found this document useful (0 votes)
36 views10 pages

Communication Theory Software

Uploaded by

Banke Bihari
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)
36 views10 pages

Communication Theory Software

Uploaded by

Banke Bihari
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/ 10

SEMESTER - IV (CBCS) and (OB~)

.
COMMUNICATION LABORATORY (21ECL46)
Gener·a1 Instructions for all the MATLAB programs
1. Click on the MATLAB icon on the desktop.
2. MATLAB window.open.
3. Click on the 'FILE' Menu on the menu bar.
4. Click.on NEW M.:.File from the File Menu.
~- An editor window opens, start typing commands.
6; Now SAVE the file in a directory in the format USN
7. Then Click on Run

L___ _ _ _ _ _ _ _ _ _...:........:_ _ EX_P_ER_I_M_E_NT_·_-_,_A_--,-_ _ _ _ _ _ _ _ _ ____,I


lilustration of AM.modulation.and demodulation and display the signal and its spectrum.
Aim: 1. To generate AM wave and to demodulate the modulated wave using MATLAB program
2. To display time do_main signals and spectrum using MATLAB program.
· ..MATLAB.Program to generate.AM wa\'e and to demodulate the modulated wave
clc;
clear all;
. close all;
fs=:8000; fm=20; fc=S00; Am=l; Ac=l;.
t=[0:.l*fs]/fs;
m=Arn*cos (2*pi*fm*'t);
c=:Ac*cos(2*pi*fc*t);

ka=0.5; u=ka*Am;
sl=Ac* (l+u*cos (2*pi*fm*t)). *cos (2*pi*fc*t) .;.
· subplot (4;3, 1: 3);
plot(t,m);
t{ tl·e ('Modulating or Message signal ( fm=20Hz) ');
subplct(4,3,4:6);
_plot(t,c);
~itle('Carrier signal(ic=500Hz)');
·subplot(4,317);
· plot(t,~1). ; .
title ('Under Modulated signa;J. ( ka .Am=0. 5) ');

Am=2; ka=0 . 5;
u=ka*Am; s2=Ac*(-l+u*cos(2*pi*fm*t)) .*cos(2*pi*fc*t); subplot(4,3,8);
plot(t,s2);
t;itle ( 'Exact Modulated signal ( ka. Am=l) ');

Am=S.i ka=:0. ~; .
• u=k~*Arn; s3=Ac* (l+u*cos (2*pi*fm*t)). *cos (2*J?i*fc*t);
subpiot(4,, 3, 9);
plot (t, s3)·;
title('Over Modulated signal(ka.Am=2.5) ');

rl= sl.*c;
%Demodulated signal . .
[b a] = butter(l,0.01);
mrl= filter(b~a,rl);

·······················--·•·.•········································· · ···············································•.•·······································24
SEMESTER - IV (CBCS) and (OBE)
COMMUNICATION U'BORATORY (21ECL46)
subplot(4,3,10);
plot(t,mrl);
title('Demodulated signal(ka.Am=0.5) ');

r2= · s2.*c;
[b a] ·= butter(i,0.01);
mr2= filte~tb,a,r2);
subplot ( 4, 3, 11) ·;
plot(t,mr2);
title('Demadulated signal(ka.Am=l) ');

r3= ~3. *c.;


[b a] = butter{l,0.01);
mr.3"': .·filte.r (b, a, r3);
subplot (4', 3, 12);
plot•(t,mr3);
· title·( '•Demodulated ·signal ( ka .Am=2. 5) • J;

EXPECTED WAVEi=ORM

0.1

o.i

.· 0.02 .0.04 O.Q6 . 0. 0.1

SPECTRUM · OF AM
%p r ogr,a:m :Qf spectrum analyzer and analysis of AM
clos.e :ali
..close ·a:11
<:l .e:a.r. · all
· clc
, . ··
'~, 25
·:••:· .··..... ·............... ·........................................... '. .:·································.·················· ······················•··············
SEMESTER- IV ·(CBCS} and (OBE)
COMMUNICATION LABORATORY (21 ECL46}

Fs = 100; %sampling frequency


t = [0:2*Fs+l] '/Fs;
Fe= 10; % Carrier frequency
x = sin(2*pi*2:l<t); % message signal
Ac~l; % Carrier amplitu~e

· %compute spectra of AM
. Xaril=ail)IllOd (x, Fe, Fs, 0, Ac) ;
zam = :f ft (xam);
zam = abs (zam(l :-l ength (zam). /2+1));
frqarn= [0:length(zam)-l]*Fs/length(zarn)/2;

% Plot spictrum of ,AM


. figure;
plot ( frqam, zam) ;
title ('Spectrum of AM signal ·• )~
Spectrum of AM signal .
10_0

90-

80-

70-

60-

50-

40-

30-

20-

10-


0 5 10 15 20 25 30 35 40 45 50 .

Result: MATLAB program is executed and AM modulation, demodulation and spectrum is plotted &
verified. ·

·'J EXPERIMENT - 1-B . .. I


·mustration.of OSB-SC modulation and demodulation and di~play the signal and its spectrum. ··
AIM: To generate and demodulate DSB-SC wave and display the signal
cl~;
clear all;
close all;
t=[0:0.001:1].;
fl=S; .
m=sin(2*pi*fl*t);
············ .. ···················································;················:................................·.........•..... '. ... :......._.... :.................26
COM~UNICATION LABORATORY (21t~L<tg/

subplot (4, 2, [ 1, 21 ) ;
plot(t,m);
title('message');
f2=80;
c=sin(2*pi*f2*t);
subplot ( 4, 2, [ 3, 4 l ) ;
plot(t,c);
title('carrier');
s=m. *c;
subplot(4,2, [5,6]);
plot(t,s); ·
title('DSB-SC');
sl=s. *·c;
[b,a]=butter(S,0.1);
s2=filter(b,a,sl);
s~bplot (4, 2, [7, 8]);
piot(t,s2);
title('demodulation');

, . 0.2 0.3 . . 0:4 0.7 , 0.8 · .. 0.9


• ,... • • r ~• W4~ ,' -4; ,Y • - - -• - - - - - ~

. . . . -
. . . .

SPECTRUM OF DSB-SC wave


· %program of spectrum analyzer and ~nalysis of DSB-SC
close all
clear .a ll
clc
Fs = 100; %sampling frequen c y
t = [0:2*Fs+l) '/fs;
Fe= 10; % ~arrier frequency
x sin(2*pi*2*t); % message signal
Ac=l; % Carrier amplitude

% compute spectra of DSB-SC wave


ydouble ammod(x,Fc,Fs, 3.14,0);
zdouble = fft (ydouble) ·;

. ··.-·····················'············································································································· .·····························27
SEMESTER - IV (CBCS) and (OBE)
COMMUNICATION LABORATORY (21ECL46)
zdouble = ~bs(zdouble(l:length(zdouble)/2+l)); .
2
frqdouble = [0:length(zdoub~e)~l]*Fs/length(zdouble)/ ,

% Plot spectrums of am dsbsc


figure;
plot(frqdouble,zdouble);
title('Spectrum of double-sideband signal');
Spectrum of double-sideband signal
50----,-----:.____:_~-~---r-----.--~---r-------c----r----'--1

45-

40-

35-

30- ·

25-

20-

15-

10-

5-


0 5 · 10 15 · 20 25 30 35 40 45 50

~-----,---,------------EX_P_E~R_IM_EN_T_-_2___,__ _ _ _ _ _ _ _ _ _ _ _ _
.·L1 __J

lll1,1stration of FM modulation.and demodulation and display the _signal and its spectrum.

Aim: To lllustrate_FM modulation and demodulation and display the signal and its spectrum using MATLAB
~, The frequency modulation (FM) waveform in time and frequency domain.
Hm=35HZ, fc=500HZ, Am=lV-,Ac=lV, B=lO
fs=<lOOOO;
Ac=l;
An\=l;
. fm=35;
fc=SOO;
B=lO;
t=(O:O.l*fs)/fs;.
wc=2*pi*fc;
wm=2*pi*fm;

m_t=An\*cos('wm*t);% Message signal


subplot(S,1,1);
plot(t,m_t);
title('Modulating or Message signa l(fm=35 Hz ) ');

···················---···········................................ ·......................................... ···- ....................................................................... -28


SEMESTER - IV (CBCS) and (OBE)
COMMUNICATION LABORATORY (21 ECL46)

c_t=Ac*cos(wc*t);% Carrier signal


subplot (5, 1, 2.);
plot(t,c_t);
title('Carrier signal(fm=500Hz) '};

s_t=Ac*cos((wc*t}+B*sin(wm*t)};% FM Modulated signal


subplot(S,1,3);
plot(t,s_t);
title ('FM Modulated signal'};_

%DEMODULATION
d=demod(s_t,fc,fs, 'fm'};
subplot(S,1.,4);
plot (t, d};
title ('FM demodulated signaJ/ ) ;

Modulating or Message signal(fm=35Hz)

J r--:::--
~~s:---r-. -7r---,,.
_. ~. 7. .~"';:/ '~~:
~'.S:
0 · 0.01 0;02 0.03 0.04 0.05 · 0.06 0.07 0.08 0.09 0.1
._ Carriersignal(fm=500Hz)

-~ WIMMMNVVVIMMWN~
0 . 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1
FM Modulated signal

-~ffiNV\NWRWVVV.V\/VVWIMINJ
0 · 0.01 0.02 0.03 0.04 0.05 0.06 0.07 0.08 0.09 0.1
FM demodulated signal

o.~ --------------
-0.5-·- - - - - - - - - - - - - - - - · -~·---·-~
0 0.01 0.02 0.03 · 0.04 0.05 0.06 0.07 0.08 0.09 0.1

SPECTUM OF FM WAVE:
~, program of spec·trum analyzer and analysis of Fm
close all
clear all
clc
Fs 100; %sampling frq
t = [0:2*Fs+l] '/Fs;
Fe= 10; % Carrier frequency
x = sin(2*pi*2*t}; % message signal
Ac=l;
~' spectrum of fm
xfm=fmmod(x,Fc,Fs,10);

··········· ............ .............................................................................................................. . 29


SEMESTER - IV (CBCS) and (OBe)
COMMUNICATION LABORATORY (21ECL46)
zfm = fft (xfm) ;
zfm = abs(zfm(l:length(zfm)/2+1));
frqfm = [0:length(zfm)-l]*Fs/length(zfm)/2;
figure;
plot ( frqfm, zfm);
title ('Spectrum of fm signa1');

Spectrum of fm signal

50

40

30

20

5 10 15 · 20 25 30 35 40 45 50

EXPERIMENT - 3
Illustrate ihe process of samplin~•and reconstruction of low pass signals. Display the signals and
.its spectrums of both analog and sampled signalsi

To illustrate the process of sampling and reconstruction of low pass signals


clc
clear all
close all
m=l;
N=20;
n=O:m:N;
d=(n==O:m:N);
f=lOO;
fs=lOOO;
b=sin(2*pi*(f/fs)*n);
y=d. *b;
subplot(3,l,l)
plot (n, b);
title('origional signal');
subplot(3,l,2)
stem(n, d);

................................................ ,. ................................................... . ··············································································30


SEMESTER - IV (CBCS) and (OBE}
COMMUNICATION LABORATORY (21ECL46)
title('impulse train');
subplot(3,l,3)
stem(n,y, 'r');
title('sampled signal/discrete signal');

origional signal

1" - I'
- -11_
impulse train
" " -~ -
I/
-
I/
"
\V - - -
V

0.5 ,-.

0
0 2 4 6 8 10 12 14 16 18 20

0 2 4 6 8 10 12 14 16
1 I: i
18 20

Effect of Nyquist rate


close all;
clear all;
clc;
t=-10:.01:10;
T=4;
fm=l/T;
x=cos(2*pi*fm*t);
subplot(2,2,l);
plot(t,x);
grid
title('continuous time. signal');
xlabel ('time .' );
ylabel('amplitude');
' nl=-4:1:4;
fsl=l.6*fm;
fs2=2*fm;
fs3=8*fm;
xl=cos(2*pi*frn/fsl*nl);
subplot(2,2,2);
stern (nl, xl )_;
title('discrete time signal with fs<2fm');
xlabel ('time');
ylabel ( 'x (n) ') ;
hold on . 31
...................................................................................................... .....
SEMESTER - IV (CBCS) and (OBE)
COMMUNICATION LABORATORY (21ECL46)

subplot(2,2,2);
piot(nl,xl);
grid
n2=-5:l:5;
'' 2=cos(2*pi*fm/fs2*n2);
subplot(2,2,3);
I
stem(n2,x2);
i itle('discrete time signal with fs=2fm');
xlabel ('time');
'I- ylabel ( 'x (n) ');
hold on
• subplot(2,2~3);
plot(n2,x2);
1·grid
~. n-3=-20:1:20;
·~3=cos(2*pi*fm/fs3*n3);
1 / subplot (2, 2, 4);

stem(n3,x3)
· '. t~tle('discrete time signal with fs>2fm');
xlabel ('time' ) ;
_ :· ylabel ( 'x (n) '. );
hold on
subplot(2,2,4);
plot(n3,x3);
grid
discrete time signal with fs<2fm
continuous time signal 1

O>
-0
:2 0
0.
E
m
-0.5 -11r<+------'_ ___,__ __,____ _ _
' -1 1.----"-'-_ __,,___,__;,_.-_,__,,__~ 0 2 4
-4 -2
-10 -5 0 5 10 time
time discrete time signal with fs>2fm
discrete time signal with fs=2fm 1 ,..--{;}---rl:,)-----l@--A-.--&-~
1 ;_.·. . . . Q - _ ( ' ; : 1 - - - _ _ - f , ; + . - - - - l ~ - ~
0.5 - - 1-H- - -H - I

--x
· C

0 10 20
5 -10
0 time
time

32

························.···················· . ········· .
/ C
SEMESTER - IV (CBCS) and (OBE)
COMMUNICATION LABORATORY (2~ECL46)

EXPERIMENT - 4
Illustration of Delta Modulation and the effects of step size selection in the design of OM
encoder
%d e l t a modulati on= 1-bit diffe r ent i al pu l s e code modulat i on (DPCM)
Predictor= (0 1]; % y(k) =x(k-1)
%partition= [-1: .1: .9];codebook = [-1 : .1:1] ;
~tep=0.2; %SFs>= 2pifA
partition= [O];~odebook = [- l*step step]; %OM qu a nti zer
• t = [O:pi/20:2*pi.J;
x = l.l*sin(2*pi ~O.l*t); % Orig i nal si gn al, a si ne wave

% Quantize ·x (t) using DPCM.


encodedx = dpcmenco(x,codebook,partition,predictor);
% Try to recover x from the m~dulat e d signal.
d.e codedx = dpcmdeco (encodedx, codebook, predictor) ;
distor = sum((x-decodedx) .A2)/length(x) % Mea n s qua re e rr or
% plots
figure,
subplot(2,2,l);plot(t,x);
xlabel(itime');title('original signal');
subplot(2,2,2);
· stairs (t, 10*.codebook (encodedx+l) , ' -- ');
xlabel('time');title('DM output'.);
subplot (2, ·2 , 3) ;plot (t,x);
hold;
stairs(t,decodedx);
grid;xlabel('time ');title('recei ved signal'); ·

original signal DM output


2 I I
I ,I !•'
I
ii ,,
I

J
I ,, I 1; ·•

' Ii ,I
,,
1

,I
0! I
ii I
I
I
-1
I
:I I-
I I

I!: I II
I
I
-2 '
-1 8. 0 2 4 6 8
2 4 6
0 time
time
received signal
2

·-1 0- - ; - -4
.
6 8
time

········································································································:..............33
·······-·

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy