mobile communication programs

Upload: safaahah

Post on 03-Jun-2018

214 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/12/2019 Mobile Communication Programs

    1/15

    Program Code 01:To generate an ASK signal.Solution:

    clc;clear all;close all;t=linspace(0,100,1000);=sin(!."t);g=input(#enter t$e se%uence g=#);l=lengt$(t);%=lengt$(g);p=(l&%);'1=1;(1:l)=0;orn=1:% ig(n)==1

    or'='1:'1*(p+1) (')=('); end

    else or'='1:'1*(p+1) (')=0; end end '1='*1;endiguresuplot(-1),plot(),title(#signal#);suplot(-),stem(g),title(#it stream#);suplot(--),plot(),title(#ASK signal#);

    enter t$e se%uence g=/0 1 1 0

  • 8/12/2019 Mobile Communication Programs

    2/15

    0 500 1000-1

    0

    1signal

    1 2 3 40

    0.5

    1bit stream

    0 500 1000-1

    0

    1ASK signal

    Program Code 0:To generate a PSK signal.Solution:

    clc;clear all;close all;t=linspace(0,100,1000);1=sin(1."t);=cos(1."t);g=/1 0 1 0 1 1;l=lengt$(t);%=lengt$(g);p=(l&%);'1=1;(1:l)=0;orn=1:%

    ig(n)==1 or'='1:'1*(p+1) (')=1('); end

    else or'='1:'1*(p+1) (')=('); end end '1='*1;

  • 8/12/2019 Mobile Communication Programs

    3/15

    endiguresuplot(-1),plot(1),title(#signal#);suplot(-),plot(),title(#p$ase s$ited signal#);suplot(--),stem(g),title(#it stream#);suplot(-!),plot(),title(#PSK signal#);

    enter the input sequence g=[0 1 1 0]

    >>

    0 500 1000-1

    0

    1signal

    0 500 1000-1

    0

    1phase shifted signal

    1 2 3 40

    0.5

    1bit stream

    0 500 1000-1

    0

    1PSK signal

    Program Code 0-:To generate a 2SK signal.

    Solution:

    clc;clear all;close all;t=linspace(0,100,1000);1=sin(1."t);=sin(."t);g=input(#enter t$e se%uence g=#);l=lengt$(t);%=lengt$(g);

  • 8/12/2019 Mobile Communication Programs

    4/15

    p=(l&%);'1=1;(1:l)=0;orn=1:% ig(n)==1 or'='1:'1*(p+1) (')=('); end

    else or'='1:'1*(p+1) (')=1('); end end '1='*1;endiguresuplot(-1),plot(1),title(#signal#);suplot(-),plot(),title(#re%uenc3 s$ited signal#);suplot(--),stem(g),title(#it stream#);suplot(-!),plot(),title(#2SK signal#);

    enter t$e se%uence g=/0 1 1 0

    0 500 1000

    -1

    0

    1signal

    0 500 1000

    -1

    0

    1frequency shifted signal

    1 2 3 40

    0.5

    1bit stream

    0 500 1000-1

    0

    1FSK signal

  • 8/12/2019 Mobile Communication Programs

    5/15

    Program Code 0!:

    To generate a 4PSK signal.

    Solution:clc;clear all;close all;t=linspace(0,50,500);t1=linspace(0,50,500);1=sin(."t1);=+sin(."t1);-=cos(."t);!=+cos(."t);g=input(#enter t$e input se%uence g=#);l=lengt$(t);%=lengt$(g);p="(l&%);'1=1;

    (1:l)=0;orn=1::% ig(n)==0 or'='1:'1*(p+1) (')=-('); end

    else or'='1:'1*(p+1) (')=!('); end end '1='*1;end'1=1;m(1:l)=0;orn=::% ig(n)==1 or'='1:'1*(p+1) m(')=1('); end

    else or'='1:'1*(p+1) m(')=('); end end '1='*1;end

    r(1:l)=0;r=*m;iguresuplot(!11),stem(g),title(#data stream#);suplot(!1),plot(),title(#odd numered se%uence#);suplot(!1-),plot(m),title(#e6en numered se%uence#);suplot(!1!),plot(r),title(#4PSK 7a6e#);

  • 8/12/2019 Mobile Communication Programs

    6/15

    enter t$e input se%uence g=/0 1 0 1

    1 1.5 2 2.5 3 3.5 40

    0.5

    1data stream

    0 50 100 150 200 250 300 350 400 450 500-1

    0

    1odd numbered sequence

    0 50 100 150 200 250 300 350 400 450 500-10

    1even numbered sequence

    0 50 100 150 200 250 300 350 400 450 500-2

    0

    2QPSK wave

  • 8/12/2019 Mobile Communication Programs

    7/15

    Program Code 05:

    To generate an OQPS signa!"

    So!ution:

    clc;clear all;close all;g=input(#8nter t$e se%uence g=#);t=linspace(0,100,1000);1=cos(1."t);=cos(1."t*pi);-=sin(1."t);!=sin(1."t*pi);suplot(!11),stem(g),title(#9it stream#);%=lengt$(g);l=lengt$(t);m=l&%;p="m;

    '1=1;1(1:l)=0;orn=1::% ig(n)==1

    or'='1:'1*(p+1) 1(')=1('); end

    else

    or'='1:'1*(p+1) 1(')=(');

    end

    end'1='*1;end31=/1 eros(1,m);suplot(!1),plot(31),title(#set 4PSK signal or t$e odd its#);'=1;(1:l)=0;

  • 8/12/2019 Mobile Communication Programs

    8/15

    orn=::% ig(n)==1

    or'=':'*(p+1) (')=-('); end

    else

    or'=':'*(p+1) (')=!(');

    end

    end'='*1;end3=/eros(1,m) ;suplot(!1-),plot(3),title(#set 4PSK signal or t$e e6en its#);(1:l)=0;=31*3;

    suplot(!1!),plot(),title(#set 4PSK signal#);ais(/100 1000 + );

    8nter t$e se%uence g=/0 1 1 1

    1 1.5 2 2.5 3 3.5 40

    0.5

    1Bit stream

    0 200 400 600 800 1000 1200 1400-1

    0

    1Offset QPSK signal for the odd bits

    0 200 400 600 800 1000 1200 1400-1

    0

    1Offset QPSK signal for the even bits

    100 200 300 400 500 600 700 800 900 1000-2

    0

    2

    Offset QPSK signal

    Program Code 0:

  • 8/12/2019 Mobile Communication Programs

    9/15

    To generate a %=/;=/m>i=/;3=/;7=10t=linspace(0,1,1000)31=cos(7"t*pi&!)3=cos(7"t*-"pi&!)3-=sin(7"t+-"pi&!)3!=sin(7"t+pi&!)ori=1::lengt$(m) m>i=/m>i m(i)

    m>%=/m>% m(i*1)endor?=1:- im>i(?)==0 im>i(?*1)==0 3=/3 3 else 3=/3 3- end else

    im>i(?)==1 im>i(?*1)==0 3=/3 31 else 3=/3 3! end end endendor?=1:- im>%(?)==0 im>%(?*1)==0 =/ 3 else =/ 3- end else

    im>%(?)==1 im>%(?*1)==0 =/ 31 else =/ 3! end end endendsuplot(!11),plot(3)

  • 8/12/2019 Mobile Communication Programs

    10/15

    suplot(!1),plot()suplot(!1-),stem(m),title(#it stream#);d=*3suplot(!1!),plot(d),title(#pi 3 our 4PSK#);

    0 500 1000 1500 2000 2500 3000-1

    01

    0 500 1000 1500 2000 2500 3000-1

    0

    1

    1 2 3 4 5 6 7 80

    0.5

    1bit stream

    0 500 1000 1500 2000 2500 3000-2

    0

    2pi by four QPSK

    Program 0@:

    To generate a 9PSK signal in a3leig$ ading c$annel, manuall3,and to plot t$e SB 6ersus t$e 98.

    Solution:

    clc;clear all;close all; 2rame Dengt$it>count = 1000;SB = 0: 1: !0;

    ora = 1: 1: lengt$(SB)T>8rrors = 0;T>its = 0; Keep going until getting 100 errors7$ileT>8rrors E 100uncoded>its = randint(1,it>count);

  • 8/12/2019 Mobile Communication Programs

    11/15

    9PSK modulator t = +"(uncoded>its+0.5);

    Boise 6ariance B0 = 1&10F(SB(a)&10);

    a3leig$ c$annel ading $ = 1&s%rt()"/randn(1,lengt$(t)) * ?"randn(1,lengt$(t));

    r>ade = $."t * s%rt(B0&)"(randn(1,lengt$(t))*i"randn(1,lengt$(t)));Gdeal 8%ualiationr>ade = r>ade.&$; 9PSK demodulator at t$e ecei6err = r>ade E 0; Calculate 9it 8rrorsdi = uncoded>its + r;T>8rrors = T>8rrors * sum(as(di));T>its = T>its * lengt$(uncoded>its);

    end

    Calculate 9it 8rror ate 98(a) = T>8rrors & T>its; disp(sprint(#it error proailit3 = #,98(aa)));end a3leig$ T$eoretical 98SBDin = 10.F(SB&10);t$eor39er = 0.5."(1+s%rt(SBDin.&(SBDin*1)));Plotting a3leig$ T$eoretical 98igure(1);semilog3(SB,t$eor39er,#+#,#DineHidt$#,);$old on; Simulated 98igure(1);semilog3(SB,98,#"g#,#DineHidt$#,);$old on;lael(#SB (d9)#);3lael(#98#);title(#SB Is 98 plot or 9PSK Jodualtion in a3leig$ C$annel#);legend(#a3leig$ T$eoretical#,#a3leig$ Simulated#);grid on;

  • 8/12/2019 Mobile Communication Programs

    12/15

    0 5 10 15 20 25 30 35 4010

    -5

    10-4

    10-3

    10-2

    10-1

    100

    SNR (dB)

    BER

    SNR Vs BER plot for BPSK Modualtion in Rayleigh Channel

    Rayleigh Theoretical

    Rayleigh Simulated

    Program 0:

    To generate a 9PSK signal in a3leig$ ading c$annel usinginuilt unction, and to plot t$e SB 6ersus t$e 98.

    Solution:clc;clear all;close all;m=randint(1,100)n=t=ps'mod(m,n)c$=ra3leig$c$an(1&10000,100)adedsig = ilter(c$,t)SB = +0::0; ange o SB 6alues, in d9.

    ori = 1:lengt$(SB) rsig = a7gn(adedsig,SB(i)); Add Laussian noise. r=ps'demod(rsig,n) /n8rrors, 98(i) = iterr(m,r);end Compute t$eoretical perormance results, or comparison.98t$eor3 = erading(SB,#ps'#,n,1);

  • 8/12/2019 Mobile Communication Programs

    13/15

    Plot 98 results.semilog3(SB,98t$eor3,#+#,SB,98,#r+#);legend(#T$eoretical 98#,#8mpirical 98#);lael(#SB (d9)#); 3lael(#98#);title(#ps' o6er a3leig$ 2ading C$annel#);

    -20 -15 -10 -5 0 5 10 15 2010

    -3

    10-2

    10-1

    100

    SNR (dB)

    BER

    bpsk over Rayleigh Fading Channel

    Theoretical BER

    Empirical BER

    Program Code 0M:

    To generate an JSK signal.

    Solution:

    clc;clear all;close all;m=linspace(0,100,!00);

    n=lengt$(31)=input(#8nter 6alue o :#); i=lengt$()T=lengt$(m)&lengt$();$=1&;t$eta0=0; p$ase at time t=0 is assumed to e 0t$etaT1=t$eta0*(pi."$)&; amount o p$ase increment 7$en s3mol 1 is sendt$etaT0=t$eta0+(pi."$)&; amount o p$ase decrement 7$en s3mol 0 is sendnc=10;1=(nc*1)&T;

  • 8/12/2019 Mobile Communication Programs

    14/15

    =(nc*)&T;const= $&("T);c1=1+const; re%uenc3 o carrier 7$en s3mol 1 is sendc=*const;re%uenc3 o carrier 7$en s3mol 0 is send31=sin(c1"pi."m *t$etaT1); carrier signal 7$en s3mol 1 is send3=sin(c"pi."m +t$etaT0); carrier signal 7$en s3mol 0 is sendi=lengt$();i(1)==1 1=/31(1:T);else 1=/3(1:T);endor?=:i

    i(?)==1 1=/1,31(1:T); else 1=/1,3(1:T);

    endendiguresuplot(-,1,1);plot(31);title(#carrier signal 7$en s3mol 1 is send#);suplot(-,1,);plot(3);title(#carrier signal 7$en s3mol 0 is send#);suplot(-,1,-);plot(1);title(#JSK signal#);

    8nter 6alue o :/1 0 1 0

  • 8/12/2019 Mobile Communication Programs

    15/15

    0 50 100 150 200 250 300 350 400-1

    0

    1carrier signal when symbol 1 is send

    0 50 100 150 200 250 300 350 400-1

    0

    1carrier signal when symbol 0 is send

    0 50 100 150 200 250 300 350 400-1

    0

    1MSK signal