Académique Documents
Professionnel Documents
Culture Documents
Program coding:
clc;
clear all;
f=500;
fc=700;
fs=100*fc;
x=Randint(1,20,[0,1]);
l=length(x);
n=0:l-1;
m=0:l*fs/f;
c=cos(2*3.14*(fc/fs)*m);
y=dmod(x,fc,f,fs,'fsk',2);
z=ddemod(y,fc,f,fs,'fsk',2);
figure();
subplot(4,1,1),stem(n,x),axis([0 20 0 1]),title('frequency shift keying'),grid,title('message
bits');
subplot(4,1,2),plot(c,'g'),axis([0 l*(fs/f) -1 1]), grid,title('carrier signal');
subplot(4,1,3),plot(y,'r'),axis([0 l*(fs/f) -1 1]), grid,title('modulated bits');
subplot(4,1,4),stem(n,z),axis([0 20 0 1],grid,title('demodulated bits');
xlabel('time period');
ylabel('amplitude');
OUTPUT:
m e s s a g e bits
1
0.5
0
10
12
c a rrie r s ig n a l
14
16
18
20
1
0
-1
5 00
1000
1500
m o d u la te d s ig n a l
2 0 00
2500
5 00
1000
1500
de m o d u la te d bits
2 0 00
2500
14
1
0
-1
am p
1
0.5
0
10
tim e
12
16
18
20
Program coding:
clc;
clear all;
f=500;
fc=800;
fs=100*fc;
x=Randint(1,20,[0,1]);
l=length(x);
n=0:l-1;
m=0:l*fs/f;
c=sin(2*pi*(fc/fs)*m);
y=dmod(x,fc,f,fs,'ask',4);
z=ddemod(y,fc,f,fs,'ask',4);
figure();
subplot(4,1,1),stem(n,x),axis([0 20 0 1]),title('amplitude shift keying'),grid,title('message
bits');
subplot(4,1,2),plot(c,'g'),axis([0 l*(fs/f) -1 1]),grid,title('carrier signal');
subplot(4,1,3),plot(y,'r'),axis([0 l*(fs/f) -1 1]),grid,title('modulated signal');
subplot(4,1,4),stem(n,z),axis([0 20 0 1]),grid,title('demodulated bits');
xlabel('time period');
ylabel('amplitude');
OUTPUT:
m e s s a g e b its
1
0 .5
0
10
12
c a rrie r s ig n a l
14
16
18
20
1
0
-1
500
1000
1500
2000
m o d u la te d s ig n a l
2500
3000
500
1000
1500
2000
d e m o d u la te d b its
2500
3000
1
0
-1
am p
1
0 .5
0
10
tim e
12
14
16
18
20
clc;
clear all;
f=500;
fc=1000;
fs=100*fc;
x=Randint(1,10,[0,1]);
l=length(x);
n=0:l-1;
m=0:l*fs/f;
c=cos(2*pi*(fc/fs)*m);
y=dmod(x,fc,f,fs,'psk',2);
z=ddemod(y,fc,f,fs,'psk',2);
figure();
subplot(4,1,1),stem(n,x),axis([0 10 0 1]),title('phase shift keying'),grid,title('message bits');
subplot(4,1,2),plot(c,'g'),axis([0 l*(fs/f) -1 1]),grid,title('carrier signal');
subplot(4,1,3),plot(y,'r'),axis([0 l*(fs/f) -1 1]),grid,title('modulated signal');
subplot(4,1,4),stem(n,z),axis([0 10 0 1]),grid,title('demodulated bits');
xlabel('time period');
ylabel('amplitude');
OUTPUT:
m e s s a ge bits
1
0.5
0
200
400
600
200
400
600
5
6
c arrie r s ign al
10
800
10 00 1200
m odu late d s igna l
1400
16 00
1800
2000
800
10 00 1200
d em od ulated bits
1400
16 00
1800
2000
10
1
0
-1
1
0
-1
am p
1
0.5
0
5
tim e
xlabel('TIME');
ylabel('AMPLITUDE');
end
figure();
for i=1:1:length(M)
ber=berawgn(EbNo,type,M(i),'nondiff');
semilogy(EbNo,ber);
hold all;
end
title('BIT ERROR PROBABILITY OF fsk');
xlabel('EbNo in dB');
ylabel('BER');
grid,legend('M=4','M=8','M=16');
OUTPUT:
fskM= 4
4
2
0
10
12
14
16
18
20
CARRIER SIGNAL
1
0
-1
500
1000
1500
2000
2500
3000
3500
2500
3000
3500
MODULATED SIGNAL
AMPLITUDE
1
0
-1
500
1000
1500
2000
DEMODULATED SIGNAL
4
2
0
10
TIME
12
14
16
18
20
fskM= 16
10
0
10
12
14
16
18
20
CARRIER SIGNAL
1
0
-1
500
1000
1500
2000
2500
3000
3500
2500
3000
3500
MODULATED SIGNAL
AMPLITUDE
1
0
-1
500
1000
1500
2000
DEMODULATED SIGNAL
10
0
10
TIME
12
14
16
18
20
OUTPUT:
pskM= 4
4
2
0
8
10
12
CARRIER SIGNAL
14
16
18
20
1
0
-1
500
1000
1500
2000
MODULATED SIGNAL
2500
3000
3500
500
1000
1500
2000
DEMODULATED SIGNAL
2500
3000
3500
1
0
AMPLITUDE
-1
4
2
0
10
TIME
12
14
16
18
20
12
14
16
18
20
pskM= 8
5
0
10
CARRIER SIGNAL
1
0
-1
500
1000
1500
2000
2500
3000
3500
2500
3000
3500
MODULATED SIGNAL
AMPLITUDE
1
0
-1
500
1000
1500
2000
DEMODULATED SIGNAL
5
0
10
TIME
12
14
16
18
20
pskM= 16
10
0
10
12
14
16
18
20
CARRIER SIGNAL
1
0
-1
500
1000
1500
2000
2500
3000
3500
2500
3000
3500
MODULATED SIGNAL
AMPLITUDE
1
0
-1
500
1000
1500
2000
DEMODULATED SIGNAL
10
0
10
10
10
BER
10
10
10
10
10
TIME
12
14
16
18
20
M =4
M =8
M =16
-1
-2
-3
-4
-5
-6
5
6
EbNo in dB
10
OUTPUT:
b it e rro r p ro b a b lilty e rro r
th e o ry :fs k -c o h
s im :fs k -c o h
b it e rro r ra te
10
10
10
10
-1
-2
-3
-4
5
6
E b /N o ,d b
10
11
OUTPUT:
b it e rro r p ro b a b lilty e rro r
th e o ry :p s k -c o h
s im :p s k -c o h
10
b it e rro r ra te
10
10
10
10
-1
-2
-3
-4
-5
-2
4
E b /N o ,d b
10
disp('DECRYPTED TEXT');
disp(char(mt));
mt(i)=tri(i,col);
end
disp('');
disp('CIPHER TEXT:');
disp(char(mt));
for i=1:length(mt)
col=mt(i)-31;
mt(i)=tri(96-i,col);
end
disp('');
disp('DECRYPTED TEXT:');
disp(char(mt));
disp('');
mt(i)=1;
for x=1:eb
mt(i)=mod(mt(i)*f,n);
end
end
disp('');
disp('CIPHER TEXT: ');
disp(mt);
%AUTHENTICATION
for i=1:length(mt)
f=mt(i);
mt(i)=1;
for x=1:db
mt(i)=mod(mt(i)*f,n);
end
end
disp('');
disp('AUTHENTICATED TEXT: ');
disp(mt);
%DECRYPTION
for i=1:length(mt)
f=mt(i);
mt(i)=1;
for x=1:ea
mt(i)=mod(mt(i)*f,n);
end
end
disp('');
disp('DECRYPTED TEXT: ');
disp(char(mt));
89
2106
CIPHER TEXT:
1676
1497
1676
AUTHENTICATED TEXT:
2106
89
DECRYPTED TEXT:
ece
2106