Ad.com.Lab Codings
Transcript of Ad.com.Lab Codings
-
7/25/2019 Ad.com.Lab Codings
1/34
1. SPECTRUM ANALYSIS OF VARIOUS MODULATION SCHEMES (BPSK):
clc;
clear all;
close all;
a=1; n=20; t=1/n;
fs=4000;
ts=1/fs;
fcarr=1000;
data=sign(randn(1,n));
st=ones((t/ts),1);
stt=st*data;
sttt=stt(:);
s=sttt>0;
fori=1:fs
if(s(i)==1)
tx(i)=a*cos(i*2*pi*fcarr/fs);
else tx(i)=a*cos(i*2*pi*fcarr/fs+pi);
end
end
y=tx;
!"=fft(y);
!"=!"(1:(fs/2));
sp=a#s(!");
f1=1:(fs/2);
se$ilogx(f1,(20*log10(sp)));
legend(%&'%);
xla#el(%freency in ert-%);
yla#el(%po.er in d#%);grid on;
OUTPUT:
1
-
7/25/2019 Ad.com.Lab Codings
2/34
QPSK:
clc;
clear all;
close all;
a=1; n=20; t=1/n;
fs=4000;ts=1/fs;
fcarr=1000;
data=sign(randn(1,n));
st=ones((t/ts),1);
stt=st*data;
sttt=stt(:);
s=sttt>0;
f1 =1:(fs/2);
fori=1:2:fs
if((s(i)==0)(s(i+1)==0))
tx(i)=a*cos((i*2*pi*fcarr/fs)+(pi/2));
tx(i+1)=a*cos((i*2*pi*fcarr/fs)+(pi/2));
elseif((s(i)==1)(s(i+1)==0))
tx(i)=a*cos((i*2*pi*fcarr/fs)+(pi));
tx(i+1)=a*cos((i*2*pi*fcarr/fs)+(pi));
end
end
end
y=tx;
!"=fft(y);
!"=!"(1:(fs/2));
sp=a#s(!");
figre(1);se$ilogx(f1,(20*log10(sp)));
legend(%'%);
xla#el(%freency in ert-%);
yla#el(%po.er in d#%);
grid on;
OUTPUT:
2
-
7/25/2019 Ad.com.Lab Codings
3/34
FSK:
clc;
clear all;
close all;
a=1; n=20; t=1/n;
fs=10000;
ts=1/fs;
fcarr=1000;
data=sign(randn(1,n));
st=ones((t/ts),1);
stt=st*data;
sttt=stt(:);
s=sttt>0;
f1 =1:fs/2;
fori=1:fs
if(s(i)==1)
tx(i)=a*cos(i*pi*fcarr/fs); else
tx(i)=a*cos(i*2*pi*fcarr*4/fs);
end
end
y=tx;
!"=fft(y);
!"=!"(1:(fs/2));
sp=a#s(!");
f1=1:fs/2;
se$ilogx(f1,(20*log10(sp)));
legend(%%);
xla#el(%freency in ert-%);yla#el(%po.er in d#%);
grid on;
OUTPUT:
3
-
7/25/2019 Ad.com.Lab Codings
4/34
ERROR PERFORMANCE:clc;
clear all;
e#no=1:20;
x=srt(e#no);
fori=1:20 #ps(i)=03*erfc(srt(105(e#no(i)/10)));
ps(i)=erfc((srt(105(e#no(i)/10)))6 1/4*(erfc(srt(105(e#no(i)/10)))52));
a$(i)=7/2*(erfc(srt(032*105(e#no(i)/10))));
fs(i)=03*exp(srt(105(03*e#no(i)/10)));
end
se$ilogy(e#no,#ps,e#no,ps,e#no,a$,e#no,fs);
xla#el(%fre(-)%);
yla#el(%#er%);
legend(%#ps%,%ps%,%a$%,%fs%);
grid on;
OUTPUT:
4
-
7/25/2019 Ad.com.Lab Codings
5/34
PERFORMANCE OF VARIOUS MODULATION SCHEMES OVER AWGN
CHANNEL:
clc;
clear all;
close all;8=1059;
d=rand(1,8)>03;
x=2*d61;
e#no=63:2:20;
si$#errayleig=-eros(1,lengt(e#no));
si$#era.gn=-eros(1,lengt(e#no));
fori=1:lengt(e#no)
noise=1/srt(2)*((randn(1,8)+i*(randn(1,8))));
=1/srt(2)*((randn(1,8)+i*(randn(1,8))));
n=noise*105(6e#no(i)/20);
ya.gn=x+n;
yrayleig=3*x+n;
yrayleigcap=yrayleig3/;
rrayleig=real(yrayleigcap)>0;
ra.gn=real(ya.gn)>0;
si$#errayleig(i)=s$(xor(d,rrayleig));
si$#era.gn(i)=s$(xor(d,ra.gn));
end
si$#errayleig=si$#errayleig/8;
si$#era.gn=si$#era.gn/8;
e#no=1035(e#no/10); trayleig=03*(16srt(e#no3/(1+e#no)));
ta.gn=03*erfc(srt(e#no));
se$ilogy(e#no,si$#errayleig,%g*6%,%line.idt%,2);
old on;
se$ilogy(e#no,si$#errayleig,%r*6%,%line.idt%,2);
old on;
se$ilogy(e#no,trayleig,%o6%,%line.idt%,2);
old on;
se$ilogy(e#no,ta.gn,%#o6%,%line.idt%,2);
old on;
axis(6 20 1056 132);
legend(%si$lated rayleig%,%si$lated a.gn%,%teorectical rayleig%,%teoretical a.gn%);
title(%
-
7/25/2019 Ad.com.Lab Codings
6/34
OUTPUT:
2. MICROWAVE COMMUNICATION:
clc;
clear all;close all;
d=inpt(%enter te dia of para#olic dises:%);
=inpt(%enter te relia#ility:%);
?=inpt(%enter te distance #et.een stations:%);
@n=inpt(%enter te c/n ratio:%);
f=inpt(%enter te fre:%);
&A=inpt(%enter te noise #.:%);
B=inpt(%enter te rogness factor:%);
&=inpt(%enter te terrain cond fact:%);
@=7*105C;
Bt=4C; Br=4C; #r=7;
Dp=(20*log10((?*4*pi*1057*f*105E)/@));F=(70*log10(?))+(10*log10)(f*B*&*9105E))6(10*log10(16))6(G0);
D#=#r*2;
Df=43G*2;
8=61G73EGG+10*log10(&A);
@$in=@n+8;
Hs=F+Dp+Df+D#6Bt6Br;
't=Hs+@$in;
H=(20*log10((d*pi*f*105E)/@));
fprintf(%In fade $argin :Jd%,F);
fprintf(%In antenna gain :Jd%,H);
fprintf(%In free space pat loss :Jd%,Dp);
fprintf(%In #rancing loss :Jd%,D#);
fprintf(%In feeder loss :Jd%,Df);
6
-
7/25/2019 Ad.com.Lab Codings
7/34
fprintf(%In @$in :Jd%,@$in);
fprintf(%In $in tranx po. :Jd%,'t);
fprintf(%In sys gain :Jf%,Hs);
OUTPUT:
OPTICAL FIBRE COMMUNICATION:
clc;
clear all;
close all;
pt=inpt(%enter te trans$itted po.er:%);
l=inpt(%enter te lengt of ca#le:%);
lc=inpt(%enter te loss per ilo$eter:%);
lf=inpt(%enter te ligt sorce to fi#re loss:%);
ll=inpt(%enter te fi#re to ligt detector loss :%);
c=inpt(%enter te n$#er of connectors:%);
cc=inpt(%enter te loss at eac conctr:%);f# =l*lc;
lc =c*cc;
ll =f#+lc+lf+ll;
pr =pt6ll;
fprintf(%rxd po.er :Jd%,pr);
7
-
7/25/2019 Ad.com.Lab Codings
8/34
OUTPUT:
MATLAB CODE FOR SATELLITE LINK DESIGN CODING:
clear all;
clc;
disp(%
pt=inpt(%
-
7/25/2019 Ad.com.Lab Codings
9/34
disp(%666666666666666666666666666666666666666%)
disp(%666666666666666666666666666666666666666%)
J
J
-
7/25/2019 Ad.com.Lab Codings
10/34
SAMPLE INPUT
@arrier po.er density at eart station antenna = 6193C00000 d&A
@/8o at te eart station receier = 10030120E d&
-
7/25/2019 Ad.com.Lab Codings
11/34
3. DIRECT SEQUENCE SPREAD SPRECTRUM
clc;
clear all;
close all;
f=rond(rand(1,70));
pattern=;
for=1:70
iff(1,)==0
sig=6ones(1,20);
else
sig=ones(1,20);
end
pattern=pattern sig;
end
s#plot(4,1,1);
plot(pattern);
axis(61 920 613 13);title(%original data seence%);
d=rond(rand(1,120));
carrier=;
pnse=;
t=0:2*pi 0:4*pi;
for=1:120
ifd(1,)==0
sig=6ones(1,);
else
sig=ones(1,);
end
c=cos(t); carrier=carrier c;
pnse=pnse sig;
end
s#plot(4,1,2);
plot(pnse);
axis(61 920 613 13);
title(%pn seence%);
ss=pattern3*pnse;
s#plot(4,1,7);
plot(ss);
axis(61 920 613 13);
title(%spreaded signal%);dss=ss3*pnse;
s#plot(4,1,4);
plot(dss);
axis(61 920 613 13);
title(%despreaded signal%);
11
-
7/25/2019 Ad.com.Lab Codings
12/34
OUTPUT:
FREQUENCY HOPPING SPREAD SPRECTRUM:
clc;
clear all;
close all;
s=rond(rand(1,2));
signal=;
carrier=;
t=(0:2*pi/11E:2*pi);
for=1:2
ifs(1,)==0; sig=6ones(1,120);
else
sig=ones(1,120);
end
c=cos(t);
carrier=carrier c;
signal=signal sig;
end
s#plot(4,1,1);
plot(signal);
axis(6100 7100 613 13);
title(%original #it seence:%);#pssig=signal3*carrier;
12
-
7/25/2019 Ad.com.Lab Codings
13/34
s#plot(4,1,2);
plot(#pssig);
axis(6100 7100 613 13);
title(%&' $odlated signal:%);
t1=(0:2*pi/E:2*pi);
t2=(0:2*pi/1E:2*pi);
t7=(0:2*pi/2E:2*pi);
t4=(0:2*pi/7E:2*pi);
t=(0:2*pi/E:2*pi);
t9=(0:2*pi/11E:2*pi);
c1=cos(t1);
c1=c1 c1 c1 c1 c1 c1 c1 c1 c1 c1 c1 c1;
c2= cos(t2);
c2=c2 c2 c2 c2 c2 c2;
c7=cos(t7);
c7=c7 c7 c7 c7;
c4=cos(t4);
c4=c4 c4 c4;c=cos(t);
c=c c;
c9=cos(t9);
spreadsignal=;
forn=1:2
c=andint(1,1,1 9);
s.itc(c)
case(1)
spreadsignal=spreadsignal c1;
case(2)
spreadsignal=spreadsignal c2;
case(7) spreadsignal=spreadsignal c7;
case(4)
spreadsignal=spreadsignal c4;
case()
spreadsignal=spreadsignal c;
case(9)
spreadsignal=spreadsignal c9;
end
end
s#plot(4,1,7);
plot((1:7000),spreadsignal);
axis(6100 7100 613 13);title(%spread signal .it 9 freency:%);
freoppedsig=#pssig3*spreadsignal;
s#plot(4,1,4);
plot((1:7000),freoppedsig);
axis(6100 7100 613 13);
title(%freency opped sprad sprectr$ signal:%);
13
-
7/25/2019 Ad.com.Lab Codings
14/34
OUTPUT:
. CHARACTERISATION OF MICROWAVE COMPONENTS
clc;
clear all;
disp(%LMDB!M%);
disp(%L8'K!: %);
's=inpt(%
-
7/25/2019 Ad.com.Lab Codings
15/34
's7=inpt(%
-
7/25/2019 Ad.com.Lab Codings
16/34
disp(coplefact1);
disp(%?irectiity (d&): %);
disp(direct1);
disp(%Lnsertion Doss (d&): %);
disp(iserloss2);
disp(%Lsolation Doss (d&): %);
disp(isoloss2);
disp(%6$atrix of ?irectional @opler: %);
disp(s$2);
disp(%FBHL@ !
-
7/25/2019 Ad.com.Lab Codings
17/34
's29=inpt(%
-
7/25/2019 Ad.com.Lab Codings
18/34
-
7/25/2019 Ad.com.Lab Codings
19/34
!. STUDY OF RADAR RANGE EQUATIONS
")DETECTION #"$% SNR
close all;
clear all;
pt = 13e+9;
fre = 39e+E;
g = 430;
sig$a = 031;
# = 30e+9;
nf = 730;
loss = 930;
range = linspace(2e7,19e7,1000);
c = 730e+C;
la$#da = c / fre;
ppea = 10*log10(pt);
la$#dasd# = 10*log10(la$#da52);forpic# = 10*log10((430 * pi)57);
d# = 10*log10(137Ce627);
tod# = 10*log10(2E0);
#d# = 10*log10(#);
rangep.r4d# = 10*log10(range354);
n$ = ppea + g + g + la$#dasd# + sig$a;
den = forpic# + d# + tod# + #d# + nf + loss + rangep.r4d#;
snr = n$ 6 den;
Jsnr = radare(pt, fre, g, sig$a, #, nf, loss, range);
range$ = range 3/ 1000;
plot(range$,snr,%line.idt%,13);
grid;xla#el (%?etection range in $%);
yla#el (%8 in d&%);
OUTPUT:
19
-
7/25/2019 Ad.com.Lab Codings
20/34
"")DETECTION #"$% POWER
close all
clear all
pt = 13e+9; J pea po.er in Aatts
fre = 39e+E; J radar operating freency in N-
g = 430; J antenna gain in d&sig$a = 031; J radar cross section in $ sared
te = 2E030; J effectie noise te$peratre in elins
# = 30e+9; J radar operating #and.idt in N-
nf = 730; Jnoise figre in d&
loss = 930; J radar losses in d&
range = linspace(2e7,19e7,1000); J range to target fro$ 2 $ 19 $, 1000 points
snr1 = radare(pt, fre, g, sig$a, te, #, nf, loss, range);
snr2 = radare(pt, fre, g, sig$a/10, te, #, nf, loss, range);
snr7 = radare(pt, fre, g, sig$a*10, te, #, nf, loss, range);
J plot 8 erss range
figre(1)
range$ = range 3/ 1000;
plot(range$,snr7,%%,range$,snr1,% 63%,range$,snr2,%:%)
grid
legend(%Isig$a = 0 d&s$%,%Isig$a = 610d&s$%,%Isig$a = 620 d&s$%)
xla#el (%?etection range 6 $%);
yla#el (%8 6 d&%);
snr1 = radare(pt, fre, g, sig$a, te, #, nf, loss, range);
snr2 = radare(pt*34, fre, g, sig$a, te, #, nf, loss, range);
snr7 = radare(pt*13C, fre, g, sig$a, te, #, nf, loss, range);
figre (2)
plot(range$,snr7,%%,range$,snr1,% 63%,range$,snr2,%:%)
gridlegend(%'t = 2319 FA%,%'t = 13 FA%,%'t = 039 FA%)
xla#el (%?etection range 6 $%);
yla#el (%8 6 d&%);
OUTPUT:
i) With respect to loss:
20
-
7/25/2019 Ad.com.Lab Codings
21/34
ii) With respect to power:
""")DETECTION RANGE FOR MISSILE AND AIRCRAFT
clc;
close all;
clear all;snr = 1730 ; J 8
sig$aF = 3; J $issile @
sig$aB = 4; J aircraft @
te = 2E030; J effectie noise te$peratre in elins
# = 1e+9; J radar operating #and.idt in N-
nf = 930; J noise figre in d&
loss = C30; J radar losses in d&
tsc = 2; J scan ti$e in seconds
tetae = 11301; J eleation se-c angle in degrees
tetaa = 790; J a-i$t searc angle in degrees
range = linspace(13e7,12e7,10000); J range to target fro$ 13 $ 12 $, 1000 points
J po.erapertre(snr,tsc,sig$a,range,te,nf,loss,,elangle)
'B'$1 = po.erapertre(snr,tsc,sig$aF,e7,te,nf,loss,tetaa,tetae)
'B'a1 = po.erapertre(snr,tsc,sig$aB,E0e7,te,nf,loss,tetaa,tetae)
'B'$ = po.erapertre(snr,tsc,sig$aF,range,te,nf,loss,tetaa,tetae);
'B'a = po.erapertre(snr,tsc,sig$aB,range,te,nf,loss,tetaa,tetae);
figre(1)
range$ = range 3/ 1000;
plot(range$,'B'$,%%,range$,'B'a,%63%)
grid
legend(%Fissile case%, %Bircraft case%)
xla#el (%?etection range 6 $%);
yla#el (%'o.er apertre prodct 6 d&%);
21
-
7/25/2019 Ad.com.Lab Codings
22/34
OUTPUT:
"&)VELOCITY
close all
clear all
pt = 13e+9; J pea po.er in Aatts
fre = 39e+E; J radar operating freency in N-
g = 4030; J antenna gain in d&
sig$a = 031; J radar cross section in $ sared
te =70030; J effectie noise te$peratre in elins
nf = 30; Jnoise figre in d&
loss = 930; J radar losses in d&
range = Ge7,100e7,10e7; J tree range ales
snrd# = linspace(,20,200); J 8 ales fro$ d& to 20 d& 200 points
snr = 1035(0313*snrd#); J conert snr into #ase 10gain = 105(031*g); Jconert antenna gain into #ase 10
loss = 105(031*loss); J conert losses into #ase 10
= 105(031*nf); J conert noise figre into #ase 10
la$#da = 73eC / fre; J co$pte .aelengt
J L$ple$ent
-
7/25/2019 Ad.com.Lab Codings
23/34
figre(1)
se$ilogy(snrd#,1e9*ta1,%%,snrd#,1e9*ta2,% 63%,snrd#,1e9*ta7,%:%)
grid
legend(% = G $%,% = 100 $%,% = 10 $%)
xla#el (%Fini$$ reired 8 6 d&%);
yla#el (%Ita (plse .idt) in I$ sec%);
OUTPUT:
'. ISDN:
clc;
clear all;
se=inpt(%
-
7/25/2019 Ad.com.Lab Codings
24/34
data=n;
fori=1:se
forO=1:ts
ifn(i,O)==1
iftest(i,O)>=1 test(i,O)P=EC0
data(i,O)=94000;
elseiftest(i,O)>EC0 test(i,O)P=EE0
data(i,O)=12C000;
elseiftest(i,O)>EE0 test(i,O)P=EEC
data(i,O)=29000;
else
data(i,O)=12000;
end
end
end
end
Jti$eslot s #and.idt
d= s$(data);figre(1);
#ar(d);
xla#el(%!i$e slot%);
yla#el(%&and.idt(#ps)%);
Jti$eslot s error rate
e=-eros(1,ts);
#$=140000;
fori=1:ts
ifd(i)>#$
e(i)=d(i)6#$;
end
endfigre(2);
#ar(e);
xla#el(%!i$eslot%);
yla#el(%1e69
#ff=#ff+10;
#$=#$+10;fori=1:ts
ife(i)>0
e(i)=d(i)6#$;
end
end
s=s$(e%);
#er=s/(ts*#$);
end
disp(%&it error rate .it #ffer%);
disp(#er);
disp(%Mpti$$ #ffer si-e%);
disp(#ff);
24
-
7/25/2019 Ad.com.Lab Codings
25/34
INPUT
-
7/25/2019 Ad.com.Lab Codings
26/34
GENERATION OF ON OFF TRAFFIC:
clc;
clear all;
x=1:10;
t=1:100;
on=inpt(%=43)
n(i,O)=1;
end
26
-
7/25/2019 Ad.com.Lab Codings
27/34
end
end
d=s$(n);
figre(2);
#ar(t,d);
xla#el(%!i$e lots%);
yla#el(%8$#er of Ksers%);
J!i$e slots Qs &and.idt
#.=94000*n;
fori=1:10
figre(7);
s#plot(,2,i);
#ar(t,#.(i,:),032)
xla#el(%!i$e lots%);
yla#el(%&A Blloted%);
end
INPUT
-
7/25/2019 Ad.com.Lab Codings
28/34
28
-
7/25/2019 Ad.com.Lab Codings
29/34
G*+$", ,- V", $*+--"/
clc;
clear all;
se=inpt(%=1 test(i,O)P=EC0
data(i,O)=94000;
else
data(i,O)=7C4000;
end
end
end
endJ!i$e lot Qs &and.idt
d=s$(data);
figre(1);
#ar(d);
xla#el(%!i$e lot%);
yla#el(%&and.idt (#ps)%);
J!i$e lots Qs #$
e(i)=d(i)6#$;end
end
figre(2);
#ar(e);
xla#el(%!i$e lot%);
yla#el(%
-
7/25/2019 Ad.com.Lab Codings
30/34
#$=#$+10;
fori=1:ts
ife(i)>0
e(i)=d(i)6#$;
end
end
s=s$(e);
#er=s/(ts*#$);
end
disp(%&it
-
7/25/2019 Ad.com.Lab Codings
31/34
31
-
7/25/2019 Ad.com.Lab Codings
32/34
0. BANDPASS FILTER:
clc;
alpap=2;
alpas=70;
o$egap=032 03C;
o$egas=034 039;
8,Ac=#ttord(o$egap,o$egas,alpap,alpas);
disp(8);
disp(Ac);
8,?e=#tter(8,Ac,%#andpass%,%s%);
disp(8);
disp(?e);
81,?e1=#ilinear(8,?e,1);
disp(81);
disp(?e1);
N,A=fre-(81,?e1);plot(A,a#s(N));
axis(0 73 0 2);
title(%freency response of #tter.ort &' sing #ilinear transfor$ation%);
xla#el(%8or$ali-ed freency%);
yla#el(%FagnitdeRN(-)R%);
OUTPUT:
32
-
7/25/2019 Ad.com.Lab Codings
33/34
HIGH PASS FILTER :
clc;
alpap=2;
alpas=G0;
o$egap=032;
o$egas=034;
8,.c=#ttord(o$egap,o$egas,alpap,alpas);
disp(8);
disp(.c);
8,?e=ce#y1(8,031,.c,%ig%,%s%);
disp(8);
disp(?e);
81,?e1=#ilinear(8,?e,1);
disp(81);
disp(?e1);
N,.=fre-(81,?e1);
plot(.,a#s(N));title(%freency response of ce#yse N' sing #ilinear transfor$ation%);
xla#el(%8or$ali-ed freency%);
yla#el(%FagnitdeRN(-)R%);
OUTPUT:
LOW PASS FILTER:
33
-
7/25/2019 Ad.com.Lab Codings
34/34
clc;
alpap=2;
alpas=70;
o$egap=032;
o$egas=034;
8,.c=ce#1ord(o$egap,o$egas,alpap,alpas);
disp(8);
disp(.c);
8,?e=ce#y1(8,031,.c,%s%);
disp(8);
disp(?e);
81,?e1=#ilinear(8,?e,1);
disp(81);
disp(?e1);
N,.=fre-(81,?e1);
plot(.,a#s(N));
title(%freency response of ce#yse D' sing #ilinear transfor$ation%);
xla#el(%8or$ali-ed freency%);yla#el(%FagnitdeRN(-)R%);
OUTPUT: