PROGRAM:
clc;
clf;
clear;
bs = input('Enter the input bit sequence :');
f = input('Enter the modulating signal frequency :');
p = input('Enter the modulating signals phase differences[p2,p3,p4] :');
a = input('Enter the modulating signal amplitude :');
c = 0;
d = 0;
l = length(bs);
if (mod(l,2) ~= 0)
bs = [bs,0];
end
% code for generating binary signal
for i = 1:l
t1 = (c:0.01:c+1);
x = bs(i) * ones(length(t1),1);
subplot(2,1,1);
plot(t1,x);
axis([0 l -1 2]);
xlabel('time ->');
ylabel('amplitude ->');
title('binary signal');
hold on
c=c+1;
end
% code for generating qpsk signal
for i=1:2:l
t=(d:0.01:d+2);
if (bs(i)==0 && bs(i+1)==0)
b = sin(2 * pi * f * t);
elseif (bs(i)==0 && bs(i+1)==1)
b = sin(2 * pi * f * t + p(1));
elseif (bs(i)==1 && bs(i+1)==0)
b = sin(2 * pi * f * t + p(2));
elseif (bs(i)==1 && bs(i+1)==1)
b = sin(2 * pi * f * t + p(3));
end
subplot(2,1,2);
plot(t,b);
xlabel('time ->');
ylabel('amplitude ->');
title('qpsk signal');
hold on
d=d+2;
end
SAMPLE OUTPUT:
Enter the input bit sequence :[0 0 0 1 1 0 1 1]
Enter the modulating signal frequency :2
Enter the modulating signals phase differences[p2,p3,p4] :[90 180 270]
Enter the modulating signal amplitude :3
PLOT:
PROGRAM:
clc;
clf;
clear;
bs = input('Enter the input bit sequence :');
f = input('Enter the modulating signal frequencies[f1 f2 f3 f4] :');
a = input('Enter the modulating signal amplitude :');
c = 0;
d = 0;
l = length(bs);
if (mod(l,2) ~= 0)
bs = [bs,0];
end
% code for generating binary signal
for i = 1:l
t1 = (c:0.01:c+1);
x = bs(i) * ones(length(t1),1);
subplot(2,1,1);
plot(t1,x);
axis([0 l -1 2]);
xlabel('time ->');
ylabel('amplitude ->');
title('binary signal');
hold on
c=c+1;
end
% code for generating qfsk signal
for i=1:2:l
t=(d:0.01:d+2);
if (bs(i)==0 && bs(i+1)==0)
b = sin(2 * pi * f(1) * t);
elseif (bs(i)==0 && bs(i+1)==1)
b = sin(2 * pi * f(2) * t);
elseif (bs(i)==1 && bs(i+1)==0)
b = sin(2 * pi * f(3) * t);
elseif (bs(i)==1 && bs(i+1)==1)
b = sin(2 * pi * f(4) * t);
end
subplot(2,1,2);
plot(t,b);
xlabel('time ->');
ylabel('amplitude ->');
title('qfsk signal');
hold on
d=d+2;
end
SAMPLE OUTPUT:
Enter the input bit sequence :[0 0 0 1 1 0 1 1]
Enter the modulating signal frequencies[f1 f2 f3 f4] :[1 8 16 32]
Enter the modulating signal amplitude :2
PLOT:
PROGRAM:
clc;
clf;
clear;
bs = input('Enter the input bit sequence :');
f = input('Enter the modulating signal frequency :');
p = input('Enter the modulating signal2 phase difference :');
a = input('Enter the modulating signal amplitude :');
c = 0;
d = 0;
l = length(bs);
% code for generating binary signal
for i = 1:l
t1 = (c:0.01:c+1);
x = bs(i) * ones(length(t1),1);
subplot(2,1,1);
plot(t1,x);
axis([0 l -1 2]);
xlabel('time ->');
ylabel('amplitude ->');
title('binary signal');
hold on
c=c+1;
end
% code for generating bpsk signal
for i = 1:l
t=(d:0.01:d+1);
if (bs(i) == 0)
b = sin(2 * pi * f * t);
else
b = sin(2 * pi * f * t + p);
end
subplot(2,1,2);
plot(t,b);
xlabel('time ->');
ylabel('amplitude ->');
title('bpsk signal');
hold on
d=d+1;
end
SAMPLE OUTPUT:
Enter the input bit sequence :[0 1 0 1 1]
Enter the modulating signal frequency :4
Enter the modulating signal2 phase difference :180
Enter the modulating signal amplitude :2
PLOT:
PROGRAM:
clc;
clf;
clear;
bs = input('Enter the input bit sequence :');
f = input('Enter the modulating signal frequencies[f1 f2] :');
a = input('Enter the modulating signal amplitude :');
c = 0;
d = 0;
l = length(bs);
% code for generating binary signal
for i = 1:l
t1 = (c:0.01:c+1);
x = bs(i) * ones(length(t1),1);
subplot(2,1,1);
plot(t1,x);
axis([0 l -1 2]);
xlabel('time ->');
ylabel('amplitude ->');
title('binary signal');
hold on
c=c+1;
end
% code for generating bfsk signal
for i = 1:l
t=(d:0.01:d+1);
if (bs(i) == 0)
b = sin(2 * pi * f(1) * t);
else
b = sin(2 * pi * f(2) * t);
end
subplot(2,1,2);
plot(t,b);
xlabel('time ->');
ylabel('amplitude ->');
title('bfsk signal');
hold on
d=d+1;
end
SAMPLE OUTPUT:
Enter the input bit sequence :[0 1 0 1 1]
Enter the modulating signal frequencies[f1 f2] :[4 15]
Enter the modulating signal amplitude :3
PLOT:
PROGRAM:
clc;
clf;
clear;
bs = input('Enter the input bit sequence :');
f = input('Enter the modulating signal frequency(Hz) :');
a = input('Enter the modulating signal amplitude :');
c = 0;
d = 0;
l = length(bs);
% code for generating binary signal
for i = 1:l
t1 = (c:0.01:c+1);
x = bs(i) * ones(length(t1),1);
subplot(3,1,1);
plot(t1,x);
axis([0 l -1 2]);
xlabel('time (s) ->');
ylabel('amplitude (v) ->');
title('BINARY SIGNAL');
hold on
c=c+1;
end
% code for generating modulating signal
mt = (0:0.01:l);
ms = a * sin(2 * pi * f* mt);
subplot(3,1,2);
plot(mt,ms);
xlabel('time (s) ->');
ylabel('amplitude (v) ->');
title('MODULATING SIGNAL');
% code for generating bask signal
for i = 1:l
t2 = (d:0.01:d+1);
y = bs(i) * a * sin(2*pi*f*t2);
subplot(3,1,3);
plot(t2,y);
xlabel('time (s) ->');
ylabel('amplitude (v) ->');
title('BASK SIGNAL');
hold on
d=d+1;
end
SAMPLE OUTPUT:
Enter the input bit sequence :[0 1 0 1 1]
Enter the modulating signal frequency(Hz) :4
Enter the modulating signal amplitude :2
PLOT: