Professional Documents
Culture Documents
Yathish PDF
Yathish PDF
In
Advanced Communication Lab
(22EC5PCACL)
By
YATHISH C S
(1BM21EC216)
close: all,
clear.».11,’
f-50;
Ü-0:1/100/f:l/f,
x=sîn{2*pi*f*f},
x1abeI ( t”! ”) ;
ylabe”1 (.' x”(t)””'
subp1öt( 312).;
stem((B.ni„xs);
t1tIe( S”änp1ed S1g”na”l x [r ï] ”' )
xta ”bè”ï ( ' ri ' ) ;
yläKeI(’x[n]’)ç
Demonstrate digital communication system
1. BASK
" n I
• "I
I ț
3. Demonstrate PCM
2 clc
2 close ’all
3 clear pll
4 t = B:0.B0B1:20;
5 c=input('€nter Bit Depth Df PCF Coding: "};
6 part = -1:B.l:1;
7 codeBsok = -l:B.1:l.lj
#temsage£|gnat
8 Ié 12 14 48 20
10 d2 J6 20
10 12 14 10 20
4. Demonstrate huffman coding and shannon fano coding
HUFFMAN CODING
end
while length(set_EoRtents) › 1
zero_probabiliiy = set_probabvlities(sorted_indices(1));
35
49
% Caltulate ihë avèra Be Muf{man codèword. ’len8.th’
av_Zength = 8;
for index’ = Ï:length(codewords)
”53 av_length = av length + proAabilitiev(index)"length(codewords(index});
5% end
55
56 d*sp(['’The ’symbol entropy Ïs: ’,num2ttF(qnfropyjj)
57 disp( [ ’ Th e a*:re r.a@ê Hufffii a Èi « ad emÖ rd I e ngtfi i s : ,’ Èium2 str (.afi l”e n h)] )
SB disp(["’The ë?ficienc): is: ',num2str(ehtropy/av_iength)])
59
’,io oi, ’,io i]i ’,[o i oj, ’,ii i oj, ’,to i ii, ;ii i ict
z o.zs ’i ö
s o.i i i o
: ü.
SHANNON CODING
clc;
2 clear q} ;
close all;
N=input( ' enter no of symkols = ');
P1=input(’enter probabilities of each symbols = ');
P=sort(P1,'de’scend');
su]=sum(P);
aq=num2str(sul); Bto convprt tp string so that while converting back to num
s u 2 =str2d nub le( aq) , $ be mill get integer .
IØ ref (su 2 =l) $t o che ck- whet her suit Of a11 the p sob ab i lity is one
h=in sgbox ( ' In rn or p co h abi lit y shou Id he one ' , ' z r r or '> ’ e r ror ’ ) ;
Æ3 else
disp(’total probability sum 1s one’};
15 end
16 [rl, cl]=size(P); %to ’find total no of probabilities given
17 %pause(5);
if(N-=c*)
19. h-msgbox('proBabi’lity dimension is dot matching with given n’o of Eymbols’,
2s
21 end
22 % following declaration in ord<r to Ullocate memory and increase speed of
:2 3 $ c al cu latio n
24 rir= z ecns.(, l N) j Sto calcu late 1+log2( l /P (1)
2S m1=zeroi(l,N); % to calculate log2(1/P(i)
26 H=0,
2T resultl=zeros(1,N); %to get code word
28 f=zeros(],N); B to fiñd cumulative probability
J9 g=zeros(2,N); %variable to store binary conversion of integer
)0 |k=zeros(],B); %to retain only ’0' or '*'
N_bar=0; %to calculate average code length
52 Cor i=I:N
33 H=H+P(i)’log2(1/(P(i))); % entropy of sourte
end
41 riix(m(i));%to get integer value
82 N_bar=N_bar+r*P( 1) ; Sto din d ave ”ra ge code Length
43 if(i==1)
44 f(i)=0;%cumulative for first
45 else
5. DEMONSTRATE DSSS AND FHSS
DSSS
12’
s d1 (4 --------temp1;
is d=lëngth(PN1);
p’1’ot(Pf4t.);
titlr('çN.üèqoenc=')r
subplot(2,2’)3’);
FHSS
carrierl=cos(timel);
.arrier5-cos(tine5};
54 careers=[terriers cqrrier5]j
sa
n=l:?0
se.' c=randi({i 6],i,i); B& Onequeucies ace nandosly are.selected by.tHe Pw generator
6 5
W Il=DsPreeO_s'8"a1 '°rri°r6):
axig - . - . .. ;
title('\bf\it frequAncy Nop#ed Spread Spectrum $iyvl’))