Anda di halaman 1dari 12

EE 6110 Digital Modulation and Coding Computer Assignment

Name-SOURAV CHATTERJEE
Roll No.-EE12M016

Program for Sinc Pulse


clc;
clear all;
tsym=1/10000;
tsamp=1/20000;
k1=-2.5*tsym:tsamp:2.5*tsym;
k2=-5.5*tsym:tsamp:5.5*tsym;
k3=-10.5*tsym:tsamp:10.5*tsym;
x1=sinc(10000*k1);
x2=sinc(10000*k2);
x3=sinc(10000*k3);
figure(1)
plot(x1,'*-')
figure(2)
plot(x2,'*-')
figure(3)
plot(x3,'*-')
nobits=45000;
d=randsrc(1,nobits);
dup=zeros(1,(tsym/tsamp)*nobits);
for i=1:nobits
dup((tsym/tsamp)*(i-1)+1)=d(i);
end
tx11=conv(dup,x1);
tx12=conv(dup,x2);
tx13=conv(dup,x3);
count1=1;
for a=6:(length(tx11)-5)
tx1(count1)=tx11(a);
count1=count1+1;
end
count2=1;
for b=12:(length(tx12)-11)
tx2(count2)=tx12(b);
count2=count2+1;
end
count3=1;
for c=22:(length(tx13)-21)
tx3(count3)=tx13(c);
count3=count3+1;
end
%figure(2)
%plot(tx)
channelfilt=[-0.022661372368211;
-0.030862771897406;
0.053733244125372;
-0.032403820840861;
-0.010959675080802;

0.014438596850867;
0.018699035670081;
-0.021062056604832;
-0.018900389562210;
0.027794050852844;
0.020215665623581;
-0.039249293809097;
-0.021124455555681;
0.059023847957180;
0.021819060957791;
-0.103252409429905;
-0.022241530126353;
0.317348702307724;
0.522383390124083;
0.317348702307724;
-0.022241530126353;
-0.103252409429905;
0.021819060957791;
0.059023847957180;
-0.021124455555681;
-0.039249293809097;
0.020215665623581;
0.027794050852844;
-0.018900389562210;
-0.021062056604832;
0.018699035670081;
0.014438596850867;
-0.010959675080802;
-0.032403820840861;
0.053733244125372;
-0.030862771897406;
-0.022661372368211];
h11=conv(tx1,channelfilt);
h12=conv(tx2,channelfilt);
h13=conv(tx3,channelfilt);
count4=1;
for d1=18:(length(h11)-19)
h1(count4)=h11(d1);
count4=count4+1;
end
count5=1;
for e=18:(length(h12)-19)
h2(count5)=h12(e);
count5=count5+1;
end
count6=1;
for f=18:(length(h13)-19)
h3(count6)=h13(f);
count6=count6+1;
end
%figure(3)
%plot(h)
c11=conv(x1,channelfilt);
c21=conv(x2,channelfilt);
c31=conv(x3,channelfilt);
count10=1;
for u1=18:(length(c11)-19)
c1(count10)=c11(u1);
count10=count10+1;
end
count11=1;

for v1=18:(length(c21)-19)
c2(count11)=c21(v1);
count11=count11+1;
end
count12=1;
for w1=18:(length(c31)-19)
c3(count12)=c31(w1);
count12=count12+1;
end
SNR=1:1:15;
for g=1:length(c1)
matched1(g)=c1(length(c1)-g+1);
end
for i1=1:length(c2)
matched2(i1)=c2(length(c2)-i1+1);
end
for j1=1:length(c3)
matched3(j1)=c3(length(c3)-j1+1);
end
%counteror=1;
for m=1:1:15
recvd1=awgn(h1,m);
recvd2=awgn(h2,m);
recvd3=awgn(h3,m);
%figure(4)
%plot(recvd)
r11=conv(recvd1,matched1);
r12=conv(recvd2,matched2);
r13=conv(recvd3,matched3);
%figure(5)
count7=1;
for n1=6:(length(r11)-5)
r1(count7)=r11(n1);
count7=count7+1;
end
count8=1;
for n2=12:(length(r12)-11)
r2(count8)=r12(n2);
count8=count8+1;
end
count9=1;
for n3=22:(length(r13)-21)
r3(count9)=r13(n3);
count9=count9+1;
end
%plot(r)
for p=1:nobits
decoded11(p)=r1(2*p-1);
end
for p=1:nobits
decoded12(p)=r2(2*p-1);
end
for p=1:nobits
decoded13(p)=r3(2*p-1);
end
for q=1:nobits

if decoded11(q)>0
decoded1(q)=1;
end
if decoded11(q)<0
decoded1(q)=-1;
end
end
for q=1:nobits
if decoded12(q)>0
decoded2(q)=1;
end
if decoded12(q)<0
decoded2(q)=-1;
end
end
for q=1:nobits
if decoded13(q)>0
decoded3(q)=1;
end
if decoded13(q)<0
decoded3(q)=-1;
end
end
eror1=0;
for r=1:nobits
if abs(d(r)-decoded1(r))~=0
eror1=eror1+1;
end
end
eror2=0;
for r=1:nobits
if abs(d(r)-decoded2(r))~=0
eror2=eror2+1;
end
end
eror3=0;
for r=1:nobits
if abs(d(r)-decoded3(r))~=0
eror3=eror3+1;
end
end
perror1(m)=eror1/nobits;
perror2(m)=eror2/nobits;
perror3(m)=eror3/nobits;
%counteror=counteror+1;
end
figure(4)
semilogy(SNR,perror1,SNR,perror2,SNR,perror3)
legend('Truncation 2','Truncation 5','Truncation 10');
axis([1 15 0 1]);
title('Error Probability for sinc pulse versus SNR')
xlabel('SNR in db');
ylabel('Probability of error');
grid on;

Output

Error Probability for sinc pulse versus SNR

10

Truncation 2
Truncation 5
Truncation 10

-1

Probability of error

10

-2

10

-3

10

-4

10

8
SNR in db

Program for raised cosine pulse


clc;
clear all;
r=1;
tsym=1/10000;
tsamp=1/20000;
x1=rrcpulse(-2.5*tsym,tsamp,2.5*tsym,r,tsamp);
x2=rrcpulse(-5.5*tsym,tsamp,5.5*tsym,r,tsamp);
x3=rrcpulse(-10.5*tsym,tsamp,10.5*tsym,r,tsamp);
figure(1)
plot(x1,'*-')
figure(2)
plot(x2,'*-')
figure(3)
plot(x3,'*-')
nobits=40000;
d=randsrc(1,nobits);
dup=zeros(1,(tsym/tsamp)*nobits);
for i=1:nobits
dup((tsym/tsamp)*(i-1)+1)=d(i);
end
tx11=conv(dup,x1);
tx12=conv(dup,x2);
tx13=conv(dup,x3);

10

12

14

count1=1;
for a=6:(length(tx11)-5)
tx1(count1)=tx11(a);
count1=count1+1;
end
count2=1;
for b=12:(length(tx12)-11)
tx2(count2)=tx12(b);
count2=count2+1;
end
count3=1;
for c=22:(length(tx13)-21)
tx3(count3)=tx13(c);
count3=count3+1;
end
%figure(2)
%plot(tx)
channelfilt=[-0.022661372368211;
-0.030862771897406;
0.053733244125372;
-0.032403820840861;
-0.010959675080802;
0.014438596850867;
0.018699035670081;
-0.021062056604832;
-0.018900389562210;
0.027794050852844;
0.020215665623581;
-0.039249293809097;
-0.021124455555681;
0.059023847957180;
0.021819060957791;
-0.103252409429905;
-0.022241530126353;
0.317348702307724;
0.522383390124083;
0.317348702307724;
-0.022241530126353;
-0.103252409429905;
0.021819060957791;
0.059023847957180;
-0.021124455555681;
-0.039249293809097;
0.020215665623581;
0.027794050852844;
-0.018900389562210;
-0.021062056604832;
0.018699035670081;
0.014438596850867;
-0.010959675080802;
-0.032403820840861;
0.053733244125372;
-0.030862771897406;
-0.022661372368211];
h11=conv(tx1,channelfilt);
h12=conv(tx2,channelfilt);
h13=conv(tx3,channelfilt);
count4=1;
for d1=18:(length(h11)-19)
h1(count4)=h11(d1);
count4=count4+1;

end
count5=1;
for e=18:(length(h12)-19)
h2(count5)=h12(e);
count5=count5+1;
end
count6=1;
for f=18:(length(h13)-19)
h3(count6)=h13(f);
count6=count6+1;
end
%figure(3)
%plot(h)
c11=conv(x1,channelfilt);
c21=conv(x2,channelfilt);
c31=conv(x3,channelfilt);
count10=1;
for u1=18:(length(c11)-19)
c1(count10)=c11(u1);
count10=count10+1;
end
count11=1;
for v1=18:(length(c21)-19)
c2(count11)=c21(v1);
count11=count11+1;
end
count12=1;
for w1=18:(length(c31)-19)
c3(count12)=c31(w1);
count12=count12+1;
end
SNR=1:1:15;
for g=1:length(c1)
matched1(g)=c1(length(c1)-g+1);
end
for i1=1:length(c2)
matched2(i1)=c2(length(c2)-i1+1);
end
for j1=1:length(c3)
matched3(j1)=c3(length(c3)-j1+1);
end
%counteror=1;
for m=1:1:15
recvd1=awgn(h1,m);
recvd2=awgn(h2,m);
recvd3=awgn(h3,m);
%figure(4)
%plot(recvd)
r11=conv(recvd1,matched1);
r12=conv(recvd2,matched2);
r13=conv(recvd3,matched3);
%figure(5)
count7=1;
for n1=6:(length(r11)-5)
r1(count7)=r11(n1);
count7=count7+1;
end
count8=1;
for n2=12:(length(r12)-11)

r2(count8)=r12(n2);
count8=count8+1;
end
count9=1;
for n3=22:(length(r13)-21)
r3(count9)=r13(n3);
count9=count9+1;
end
%plot(r)
for p=1:nobits
decoded11(p)=r1(2*p-1);
end
for p=1:nobits
decoded12(p)=r2(2*p-1);
end
for p=1:nobits
decoded13(p)=r3(2*p-1);
end
for q=1:nobits
if decoded11(q)>0
decoded1(q)=1;
end
if decoded11(q)<0
decoded1(q)=-1;
end
end
for q=1:nobits
if decoded12(q)>0
decoded2(q)=1;
end
if decoded12(q)<0
decoded2(q)=-1;
end
end
for q=1:nobits
if decoded13(q)>0
decoded3(q)=1;
end
if decoded13(q)<0
decoded3(q)=-1;
end
end
eror1=0;
for r=1:nobits
if abs(d(r)-decoded1(r))~=0
eror1=eror1+1;
end
end
eror2=0;
for r=1:nobits
if abs(d(r)-decoded2(r))~=0
eror2=eror2+1;
end
end
eror3=0;
for r=1:nobits
if abs(d(r)-decoded3(r))~=0
eror3=eror3+1;
end

end
perror1(m)=eror1/nobits;
perror2(m)=eror2/nobits;
perror3(m)=eror3/nobits;
%counteror=counteror+1;
end
figure(4)
semilogy(SNR,perror1,SNR,perror2,SNR,perror3)
legend('Truncation 2','Truncation 5','Truncation 10');
axis([1 15 0 1]);
title('Error Probability for rrc pulse versus SNR')
xlabel('SNR in db');
ylabel('Probability of error');
grid on;

Function rrcpulse
function [h]=rrcpulse(lowlim,incre,highlim,r,tsamp)
count=1;
for n=lowlim:incre:highlim
if (n==0)
h(count)=1-r+(4*r/pi);
elseif (n==(tsamp/(4*r))||n==(-tsamp/(4*r)))
h(count)=(r/sqrt(2))*((1+2/pi)*sin(pi/(4*r))+(12/pi)*cos(pi/(4*r)));
else
h(count)=(sin(pi*(1r)*(n/tsamp))+4*r*(n/tsamp)*cos(pi*(1+r)*(n/tsamp)))/(pi*(n/tsamp)*(116*r*r*(n/tsamp)*(n/tsamp)));
end
count=count+1;
end

Output

Error Probability for rrc pulse (100% excess bandwidth) versus SNR

10

Truncation 2
Truncation 5
Truncation 10
-1

Probability of error

10

-2

10

-3

10

-4

10

8
SNR in db

10

12

14

Error Probability for rrc pulse (10% excess bandwidth) versus SNR

10

Truncation 2
Truncation 5
Truncation 10

-1

Probability of error

10

-2

10

-3

10

-4

10

8
SNR in db

10

12

14

Error Probability for rrc pulse (50% excess bandwidth) versus SNR

10

Truncation 2
Truncation 5
Truncation 10
-1

Probability of error

10

-2

10

-3

10

-4

10

8
SNR in db

10

12

14

Anda mungkin juga menyukai