Sei sulla pagina 1di 16

eIIove *rmstztr*te ‹of ecflr*‹o}cmgy

NAME - ARKAJYOTI SAHA

REG. NO. - 18BEC0938

SLOT - L37+L38

DCS LAB ASSESSMENT -3

ASSIGNED BY - PROFF. THANIKAISELVAN

Vellore Institute of Technology


Amplitude Shift Keying (ASK) signal

clc
clear all;
close all;
b=[1 0 1 0]; % 4 bits are taken as an input
% b to b(t) --using unipolar NRz singalling
% Tb- bit duration Tb=1sec
% 4 bits then totally we need 4secs to accomodate 4 bits
t=0:0.01:length(b)-0.01;
bb=[]% bb is b(t)
j=1;
for i=1:length(t)
if t(i)<j
bb(i)=b(j)
else
j=j+1
end
end
% carrier signal
c=2*sin(2*pi*2*t);
% Amplitude Shift Keying (ASK)signal
s=bb.*c;
subplot(4,1,1)
plot(t,bb)
title('Message signal')
xlabel('time')
ylabel('Amplitude');
subplot(4,1,2) plot(t,c)
title('carrier signal')
xlabel('time')
ylabel('Amplitude');
subplot(4,1,3) plot(t,s)
title('ASK signal')
xlabel('time')
ylabel('Amplitude');
d=[]; % demodulated signal
for i=1:length(s)
if s(i)==0
d(i)=0;
else
d(i)=1;
end
end
subplot(4,1,4)
plot(t,d)
title('Demodulated signal');
xlabel('time')
ylabel('Amplitude');
end
% carrier signal
c=2*sin(2*pi*2*t);
25 % Amplitude Shift Keying (ASK)signal
s=bb.*c;

28 subplot(4,1,1)
plot(z,bb)
30 title('Message signal')
31 xlabel('mime')
32 ylabel('Amplitude');

34 subplot(4,1,2)
s plot (z, c )
sG title('carrier signal')
37 x1abe1( ' z fee ' )
38 y1abe1( ' Anp13.t ude ' ) ;
I? s ubplot (4, 1, 3)
40 plOt(z,S)
<i title('ASK signal ')
42 xlabel('mime')
J7 — xlabel('cime')
3g ylabel('Ampl:tude');
3s — subplot(4,1,3)
40 plot(t,s)
41 title('ASK signal')
42 xlabel('mime')
41 ylabel('Ampl1tude');

o5 - d=[]; % demodulated signal


4c for i=1:length(s)
a7 if s(i)==0
4g d(i)=0;
4s else
so d(i)=1;
51 end
52 end
subplot(4,1,4)
54 plot(t,d)
55 title('Demodulated signal');
ss xlabel('time')
ylabel('Amplitude');
Frequency Shift Keying (FSK) Signal

clc
clear all;
close all;
% Frequency Shift Keying
b=[1 0 1 0]; % 4 bits are taken as an input
% b to b(t) --using unipolar NRz singalling
% Tb- bit duration Tb=1sec
% 4 bits then totally we need 4secs to accomodate 4 bits
t=0:0.01:length(b)-0.01;
bb=[]% bb is b(t)
j=1;
for i=1:length(t)
if t(i)<j
bb(i)=b(j)
else
j=j+1
end
end
% carrier signal
c1=2*sin(2*pi*2*t);
c2=2*sin(2*pi*5*t);
s=[]% FSK signal
for i= 1:length(bb)
if bb(i)==1
s(i)=c1(i)
else
s(i)=c2(i)
end
end
subplot(5,1,1)
plot(t,bb)
title('Message signal')
xlabel('time')
ylabel('Amplitude');
subplot(5,1,2) plot(t,c1)
title('carrier signal 1')
xlabel('time')
ylabel('Amplitude');
subplot(5,1,3)
plot(t,c2)
title('carrier signal 2')
xlabel('time')
ylabel('Amplitude');
subplot(5,1,4)
plot(t,s)
title('FSK signal')
xlabel('time')
ylabel('Amplitude');
d=[]; % demodulated signal
for i=1:length(s)
if s(i)==c1(i)
d(i)=1;
else
d(i)=0;
end
end
subplot(5,1,5)
plot(t,d)
title('Demodulated signal');
xlabel('time')
ylabel('Amplitude');
dcs UnipoIarSignaIIing.m ice PDD ño»pai.sio».i» ‹Pcs ASK TASK !t dcs FSK
1 clc
2 clear all;
3 close all;
4 % Frequency Shift Keying
5
G - b=[1 0 1 0]; % 4 bits are taken as an input
7
% b to b(t) --using unipolar NRz singalling
% Tb- bit duration Tb=1sec
10 % 4 bits then totally we need 4secs to accomodate 4 bits

t=8:8.B1:length(b)-B.B1;

bb= ]% bb is b(t)
15 -1,
for i=1:length(t)
if t(i)‹j
i8 bb(i)=b(j)
else

21 end
22
23 end
2? — end
24 % carrier signal
25 c1=2*sin(2*pi*2*t);
2G C2=2*sin(2•pi*5*t);
27
29 - s=[]% FSK signal
25 — for i= 1:length(bb)
sd — if bb(i)==1
s1 - s(i)=c1(i)
else
s(i)=c2(i)
34 end
end

37
39 — subplot(5,1,1)
plot (z, bb)
40 tit ie ( ' He s sage signa1' )
4’I x1abe1( ' c me ' )
y1abe1( ' Amp 1 itude ' ) j
44 subplot(5,1,2)
45 - plot(t,c1)
45 title(' carrier signal l')
47 - xlabel('iime')
4B ylabel('Amplitude');
49
50 subplot(5,1,3)
51 plot(t,c2)
52 title('carrier signal 2')
5s — xlabel('iime')
54 ylabel('Amplitude');
55
5o subplot(5,1,4)
57 plot(t,s)
59 title('FSK signal')
52 xlabel('time')
60 ylabel('Ampliiude');
61
s2 - d=[]; % demodulated signal
6J - for i=1:length(s)
64 if s(i)==c1(i)
65 d(i)=1;

S2 — d=[]; % demodulated signal


c3 for i=1:length(s)
s4 if s(i)==cl(i)
65 d(i)=1;
s6 else
67 d(i)=0;
ss end
C9 — end
7s subplot(5,1,5)
71 - plot(t,d)
title('Demodulated signal ');
73 xlabel('time')
74 ylabel('Amplitude');
...... „. ......... I
OUTPUT IN MATLAB

Message signal

15 3 as
time
carrier signal 1

2
o
05 1 15 2 25 3 IS 4
Jme

FSK signal

0.5 2 zs 3 3.5 4
time
Demodulated signal

05 15 2 s 3 35
tme
Phase Shift Keying (PSK) Signal

clc
clear all;
close all;
% Phase Shift Keying
b=[1 0 1 0]; % 4 bits are taken as an input
% b to b(t) --using unipolar NRz singalling
% Tb- bit duration Tb=1sec
% 4 bits then totally we need 4secs to accomodate 4 bits
t=0:0.01:length(b)-0.01;
bb=[]% bb is b(t)
j=1;
for i=1:length(t)
if t(i)<j
bb(i)=b(j)
else
j=j+1
end
end
% carrier signal
c1=2*sin(2*pi*2*t);
c2=-2*sin(2*pi*2*t);
s=[]% FSK signal
for i= 1:length(bb)
if bb(i)==1
s(i)=c1(i)
else
s(i)=c2(i)
end
end
subplot(5,1,1)
plot(t,bb)
title('Message signal')
xlabel('time')
ylabel('Amplitude');
subplot(5,1,2)
plot(t,c1)
title('carrier signal 1')
xlabel('time')
ylabel('Amplitude');
xlabel('time')
ylabel('Amplitude');
subplot(5,1,3)
plot(t,c2)
title('carrier signal 1 with 180deg phase shifted')
xlabel('time')
ylabel('Amplitude');
subplot(5,1,4)
plot(t,s)
title('PSK signal')
xlabel('time')
ylabel('Amplitude');
d=[]; % demodulated signal
for i=1:length(s)
if s(i)==c1(i)
d(i)=1;
else
d(i)=0;
end
end
subplot(5,1,5)
plot(t,d)
title('Demodulated signal');
xlabel('time')
ylabel('Amplitude');
1 clc
2 clear all;
3 close all;
4 % Phase Shift Keying
5
i - b=[1 0 1 0]; % 4 bits are taken as an input

% b to b(t) --using unipolar NRz singalling


% Tb- bit duration Tb=1sec
10 % 4 bits then totally we need 4secs zo accomodate 4 bits

t=0:0.01:length(b)-0.01;

;a — bb=[]% bb is b(t)
15 J'#T
;c for i=1:length(t)
17 t(i)‹j
-h

ia bb(i)=b(j)
ls else
j=j+1
21 end

23 end!
end
24 % carrier signal
25 c1=2*sin(2•pi*2*t);
c2=-2*sin(2*pi*2*t);
27
s=[]% FSK signal
for i= 1:lengtn(bb)
30 if bb(i)==l
» s(i)=c1(i)
else
s ( i ) =c 2 ( 1}
end
35 end
35
37
ss subplot(5,1,1)
plot(t,bb)
40 title('Message signal')
41 xlabel('time')
42 ylabel('Amplitude');
43 subplot(5,1,2)
44 plot(t,c1)
45 — title('carr er s gnal I')
45 — title('carrier signal l')
46 — xlabel('mime')
47 - ylabel('Amplitude');
A8 — xlabel('time')
4s ylabel('Amplitude');
50 Subplot(5,1,3)
51 plot(t,c2)
5 — title('carrier signal l With l80deg pnase sni+ted ')
53 - xlabel('i1me')
54 — ylabel('Amplitude');
55 — subplot(5,1,4)
s6 - plot(t,s
s7 title('PSK signal')
5g xlabel('mime')
59 ylabel('Amplitude');
60 - d=[]; % demodulated signal
s1 for i=1:length(s)
62 — if s(i)==c1(i)
Gs d(i)=1;
64 else
d(i)=0;
6 end

55 subplot(5,1,4)
56 plot(t,s)
s7 title('PSK signal')
58 xlabel('time')
s9 ylabel('Amplitude');
G0 — d=[]; % demodulated signal
61 for i=1:length(s)
G2 — if s(i)==cl(i)
6a d ( i ) =1;
6s else
o5 d(i)=0;
6^ end
67 end
68 subplot(5,1,5)
su — plot(t,d)
70 title('Demodulated signal');
71 — xlabel('time')
72 ylabel('Amplitude');
OUTPUT IN MATLAB
Message signal
1

0
o’
0 05 1.5 25 35

time

Potrebbero piacerti anche