clc;
clear;
close;
t=linspace(0,1,1000);
//f=input('enter the message frequency');
f=1;
m=0.5+0.5*cos(2*%pi*f*t);
subplot(3,2,1);
plot(t,m);

title('message signal');
c=zeros(1,1000);
c1=zeros(1,1000);
v=1:100:1000;
for i=1:length(v)
    c(v(i):v(i)+30)=1;
    c1(v(i)+50:v(i)+80)=0.8;
end
subplot(3,2,2);
plot(t,c);

title('carrier pulse');
pam=zeros(1,1000);
pam1=zeros(1,1000);
for i=1:length(v)
    pam(v(i):v(i)+30)=c(v(i))*m(v(i));
    pam1(v(i)+50:v(i)+80)=c1(v(i)+50)*m(v(i)+50);
end
subplot(3,2,3);
plot(t,pam);
title('pulse amplitude modulation of c1');

subplot(3,2,4);
plot(t,c1);
title('carrier signal');

subplot(3,2,5);
plot(t,pam1);
title('pulse amplitude modulation of c2');

subplot(3,2,6);
plot(t,pam);plot(t,pam1,'r')
title('tdm signal');

