Communication Theory Software
Communication Theory Software
.
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
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) ');
EXPECTED WAVEi=ORM
0.1
o.i
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}
· %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;
90-
80-
70-
60-
50-
40-
30-
20-
10-
o·
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. ·
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');
. . . . -
. . . .
. ··.-·····················'············································································································· .·····························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)/ ,
45-
40-
35-
30- ·
25-
20-
15-
10-
5-
o·
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;
%DEMODULATION
d=demod(s_t,fc,fs, 'fm'};
subplot(S,1.,4);
plot (t, d};
title ('FM demodulated signaJ/ ) ;
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);
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
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
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
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
·······-·