You are on page 1of 3

Name : Wasim Shaikh REG NO: 2020BEC119

Sub : Digital Communication

PRACTICAL : 02

Aim : To Study Ask Modulation and Demodulation.

Matlab Code:
clc ;
close all;
clear all;
A=input("Enter the bit sequence in [ ]:");
length_A=length(A);
if (A(length_A)==1)
A(length_A+1)=1;
else
A(length_A+1)=0;
end
Amplitude=3;
time=0:0.001:1;
fc=20; % Carrior frequency

c=Amplitude*sin(2*pi*fc*time);
%ASK Modulation Part
for I =1:length_A
for j=(i-1)*50:(i*50)
if A(i)==1
y(j+1)=c(j+1);
else
y(j+1)=0;
end
end
end
%ASK Demodulation Part
for i=1:length_A
for j=(i-1)*50:i*50

if A(i)==1
g(j+1)=c(j+1)./c(j+1);
else

g(j+1)=0;
end
end
end

%ASK Plotting
subplot(4,1,1)
stairs(A)
ylim([-2 2])
ylabel("A(t)in bits");
xlabel("t");
title('Bit Sequence');

subplot(4,1,2)
plot(time,c)
ylabel("Amplitude");
xlabel("t");
title('Carrier Signal');

subplot(4,1,3)
plot(y)
ylabel("Amplitude");
xlabel("t");
title('ASK Modulation');

subplot(4,1,4)
plot(g)
ylim([-2 2])
ylabel("A(t)in bits");
xlabel("t");
title('ASK Demodulation');
Output:

You might also like