Space In HIndi

 


Pages

Popular

ITCT and CN- ALL PRACTICAL

Expt-1 Implementation of algorithm for determination of various entropy and mutual information 

k=input('Enter the joint probability')
[m,n]=size(k)
for a=1:m
px(a)=sum(k(a,:))
end
%calculation of p(y)
for b=1:n
py(b)=sum(k(:,b))
end
Hx=0
for c=1:m
hx=px(c)*[log(1/py(d))/log(2)]
Hxy=Hxy+hxy
end
end
Hx_y=Hxy-Hy
Hy_x=Hxy-Hx
%calculation of I(x,y)
Ixy=Hx+Hy-Hxy


Expt2-Implementation of algorithm for generation and evaluation of variable length source coding using Huffman algorithm

Program 
clc 
symbols=input('Enter symbols');
p=input('enter probability');
m=length(p);
[dict,avglen]=huffmandict(symbols,p)
dict{:,:}
testsig=randsrc(1,10,[symbols;p]) 
encode=huffmanenco(testsig,dict) 
decode=huffmandeco(encode,dict)
flag=isequal(testsig,decode)
hx=0
for i=1:m
hx=hx-[p(i)*log2(p(i))];
end;
hx
eta=(hx/avglen)*100

Expt 3:-Linear Block Code
program-
n=input('enter the block length n=');
k=input('enter the msg bit length k=') ;
p=input('enter the parity matrix p=');
G=[eye(k),p]
H=[p',eye(n-k)]
m=2^k;
a=[0:m-1]
msg=de2bi(a,'left-msb');
cword=msg*G
codeword=mod(cword,2)
wt=sum(codeword,2)
wt(1)=[];
dmin=min(wt)
errordetection=dmin-1
H_trans=H';
e=eye(n);
z=zeros(1,n);
E=[z;e]
s1=E*H_trans
dec=[E,s1]
r=input('enter the received vector r=');
s=r*H_trans;
S1=mod(s,2)
for i=1:n+1
     if S1(1,:)==s1(i,:)
     erp=E(i,:)
     end
end 
c_correct=xor(r,erp)

Expt 4:- Cyclic codes
clc 
clear all
n=input('enter the length polynomial(n)=')
k=input('enter length of message bit(k)=')
order=n-k
p=zeros(1,order+1)
p(1)=1
m=2^k
a=[0:m-1]
msg=de2bi(a,'left-msb')
g=cyclpoly(n,k,'max')
for j=1:m
      product(j,:)=conv(p,msg(j,:));
      [q,rem(j,:)]=deconv(product(j,:),g);
      rem=mod(rem,2);
end
codeword=product+rem
e=eye(n)
z=zeros(1,n);
E=[z;e];
for j=1:n+1
[q,s1(j,:)]=deconv(E(j,:),g)
s1=mod(s1,2)
end
r=input('enter the received vector r=')
 [q,S1]=deconv(r,g);
S1=mod(S1,2)
for j=1:n+1
if S1(1,:)==s1(j,:)
erp=E(j,:)
end 
end 
c_correct=xor(r,erp)


Expt 5:-Convolutional  encoding and decoding
 n=input('enter the length of codeword frame=');
L=input('enter the length of message vector=');
M=input('enter the no of flipflops=');
msg=input('enter the message bit');
g1=input('enter the impulse response of adder 1=');
g2=input('enter the impulse response of adder 2=');
 K=M+1
msg=[msg,zeros(1,K-1)]
b=num2str(g1)
c=num2str(g2)
cv1=str2num(dec2base(bin2dec(g1),8)
cv2=str2num(dec2base(bin2dec(g2),8)
cv=[cv1,cv2]
trellis=poly2trellis(K,cv)
code=convenc(msg,trellis)
r=input('enter the received codeword =')
tblen=input('enter the tranceback length=')
opmode=input('enter the opmode=')

dectype=input('enter the decttype=')
decoded=vitdec(r,trellis,tblen,opmode,dectype)

Expt 6:BCH encoding and decoding

clc;
n=input('enter the code word length=');
k=input('enter the msg length=');
nw=input('enter the no. of words to process=');
msg=gf(randint(nw,k))%random k symbol msg and data     represented using Galois field 
[genpoly,t]=bchgenpoly(n,k);
t2=t;
code=bchenc(msg,n,k)
noisecode=code+randerr(nw,n,1:t2)%Corrupt up to t2 bits in each codeword.
if ccode==code
   disp('All errors were corrected.')
end 
if new msg==msg 
  disp('The message was recovered perfectly.')
end

No comments: