Pulse Amplitude Modulation (PAM)
MATLAB Script
clc;
clear all;
close all;
fm= 10; % frequency of the message signal
fc= 100; % frequency of the carrier signal
fs=1000*fm; % (=100KHz) sampling frequency (where 1000 is the upsampling factor)
t=0:1/fs:1; % sampling rate of (1/fs = 100 kHz)
m=1*cos(2*pi*fm*t); % Message signal with period 2*pi*fm (sinusoidal wave signal)
c=0.5*square(2*pi*fc*t)+0.5; % square wave with period 2*pi*fc
s=m.*c; % modulated signal (multiplication of element by element)
subplot(4,1,1);
plot(t,m);
title('Message signal');
xlabel ('Time');
ylabel('Amplitude');
subplot(4,1,2);
plot(t,c);
title('Carrier signal');
xlabel('Time');
ylabel('Amplitude');
subplot(4,1,3);
plot(t,s);
title('Modulated signal');
xlabel('Time');
ylabel('Amplitude');
%demdulated
d=s.*c; % At receiver, received signal is multiplied by carrier signal
filter=fir1(200,fm/fs,'low'); % low-pass FIR filter which order is 200
% here fm is the cut-off frequency and the fs is the sampling frequency
original_t_signal=conv(filter,d); % convolution of demodulated signal with filter %coefficient
t1=0:1/(length(original_t_signal)-1):1;
subplot(4,1,4);
plot(t1,original_t_signal);
title('demodulated signal');
xlabel('time');
ylabel('amplitude');