ee12m016

Embed Size (px)

Citation preview

  • 7/29/2019 ee12m016

    1/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);endtx11=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;

    endcount2=1;

    for b=12:(length(tx12)-11)tx2(count2)=tx12(b);count2=count2+1;

    endcount3=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;

  • 7/29/2019 ee12m016

    2/12

    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;

    endcount5=1;for e=18:(length(h12)-19)

    h2(count5)=h12(e);count5=count5+1;

    endcount6=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;

    endcount11=1;

  • 7/29/2019 ee12m016

    3/12

    for v1=18:(length(c21)-19)c2(count11)=c21(v1);count11=count11+1;

    endcount12=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);endfor i1=1:length(c2)

    matched2(i1)=c2(length(c2)-i1+1);endfor 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;

    endcount8=1;for n2=12:(length(r12)-11)

    r2(count8)=r12(n2);count8=count8+1;

    endcount9=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);endfor p=1:nobits

    decoded12(p)=r2(2*p-1);endfor p=1:nobits

    decoded13(p)=r3(2*p-1);end

    for q=1:nobits

  • 7/29/2019 ee12m016

    4/12

    if decoded11(q)>0decoded1(q)=1;

    endif decoded11(q)0

    decoded2(q)=1;endif decoded12(q)0decoded3(q)=1;

    end

    if decoded13(q)

  • 7/29/2019 ee12m016

    5/12

    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);endtx11=conv(dup,x1);tx12=conv(dup,x2);tx13=conv(dup,x3);

    2 4 6 8 10 12 14

    10-4

    10-3

    10-2

    10-1

    100

    SNR in db

    Pro

    bability

    oferror

    Error Probability for sinc pulse versus SNR

    Truncation 2

    Truncation 5

    Truncation 10

  • 7/29/2019 ee12m016

    6/12

    count1=1;for a=6:(length(tx11)-5)

    tx1(count1)=tx11(a);count1=count1+1;

    endcount2=1;

    for b=12:(length(tx12)-11)tx2(count2)=tx12(b);count2=count2+1;

    endcount3=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;

  • 7/29/2019 ee12m016

    7/12

    endcount5=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;endcount11=1;for v1=18:(length(c21)-19)

    c2(count11)=c21(v1);count11=count11+1;

    endcount12=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);

    endfor i1=1:length(c2)

    matched2(i1)=c2(length(c2)-i1+1);endfor 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;

    endcount8=1;for n2=12:(length(r12)-11)

  • 7/29/2019 ee12m016

    8/12

    r2(count8)=r12(n2);count8=count8+1;

    endcount9=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);endfor p=1:nobits

    decoded12(p)=r2(2*p-1);endfor p=1:nobits

    decoded13(p)=r3(2*p-1);end

    for q=1:nobitsif decoded11(q)>0

    decoded1(q)=1;endif decoded11(q)0decoded2(q)=1;

    end

    if decoded12(q)0decoded3(q)=1;

    endif decoded13(q)

  • 7/29/2019 ee12m016

    9/12

    endperror1(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))+(1-

    2/pi)*cos(pi/(4*r)));else

    h(count)=(sin(pi*(1-

    r)*(n/tsamp))+4*r*(n/tsamp)*cos(pi*(1+r)*(n/tsamp)))/(pi*(n/tsamp)*(1-

    16*r*r*(n/tsamp)*(n/tsamp)));end

    count=count+1;

    end

    Output

  • 7/29/2019 ee12m016

    10/12

    2 4 6 8 10 12 1410

    -4

    10-3

    10-2

    10-1

    100

    SNR in db

    P

    robability

    oferror

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

    Truncation 2

    Truncation 5

    Truncation 10

  • 7/29/2019 ee12m016

    11/12

    2 4 6 8 10 12 14

    10-4

    10-3

    10-2

    10-1

    100

    SNR in db

    Probability

    oferror

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

    Truncation 2

    Truncation 5

    Truncation 10

  • 7/29/2019 ee12m016

    12/12

    2 4 6 8 10 12 14

    10-4

    10-3

    10-2

    10-1

    100

    SNR in db

    Probability

    oferror

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

    Truncation 2

    Truncation 5

    Truncation 10