%pulse amplitude modulation
%1. to study the pulse amp and demod
%2. to study pulse width
%3. to generate pulse positiob=n
% Pulse Amplitude Modulation (PAM)
close all; clear; clc;
t = 0:1/1e3:10;     
d = 0:1/5:10;       
x = 5 + sin(2*pi*(1/4)*2*t); 
figure;
subplot(3,1,1);
plot(t, x);
title('Message Signal');
xlabel('Time (s)');
ylabel('Amplitude');

% Generate pulse input
y = pulstran(t, d, 'rectpuls', 0.1);
subplot(3,1,2);
plot(y);
title('Pulse Input');
xlabel('Time (s)');
ylabel('Amplitude');

% PAM modulation
z = x.*y;
subplot(3,1,3);
plot(z);
title('PAM Modulated Signal');
xlabel('Time (s)');
ylabel('Amplitude');
sgtitle('Sujal Singh (04119051723)')
