%to generate modulate and demodulate amplitude shift key(ASK signal) using
%matlab essential software with communication tool box
clc;
clear all;
close all;
Tb = 1;
fc = 10;
t=0:Tb/100:1;
c=sqrt(2/Tb)*sin(2*pi*fc*t);
N=8;
m=rand(1,N);
t1=0;
t2=Tb;
for i=1:N
t=[t1:.01:t2]
if m(i)>0.5
m(i)=1;
m_s=ones(1,length(t));
else
m(i) = 0;
m_s = zeros(1,length(t));
end
message(i,:)=m_s;
ask_sig(i,:)=c.*m_s;
t1 = t1+(Tb + 0.1);
t2 = t2 + (Tb+0.1);
subplot(5,1,2);
axis([0 N -2 2]);
plot(t,message(i,:),'r');
hold on
subplot(5,1,4);
plot(t,ask_sig(i,:));
hold on
end
hold off
subplot(5,1,3);
plot(t,c);
sgtitle('Sujal Singh (04119051723)')