-
Notifications
You must be signed in to change notification settings - Fork 4
/
CE_PAM.m
51 lines (43 loc) · 870 Bytes
/
CE_PAM.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
clc;
close all;
clear all;
samples = 1000;
fm = 3;
%fc = 15*fm;
Am = 1;
Ac = 1;
fs = 10;
t = linspace(0,1,samples);
m_t = Am*cos(2*pi*fm*t);
% PAM Signal
c_t = zeros(1,samples);
for i = 1:20:samples
c_t(1, i:i+9) = 1;
c_t(1, i+10:i+19) = 0;
end
s_t = m_t.*c_t;
figure(1)
subplot(4,1,1);
plot(t,m_t);
title('Message Signal (1904215)');
xlabel('Time Axis');
ylabel('Amplitude');
subplot(4,1,2);
plot(t,c_t);
title('Pulse Train Signal (1904215)');
xlabel('Time Axis');
ylabel('Amplitude');
subplot(4,1,3);
plot(t,s_t);
title('Pulse Amplitude Modulation (1904215)');
xlabel('Time Axis');
ylabel('Amplitude');
%demodulation
dt = s_t.*c_t;
[b,a] = butter(5,0.01);
retrieved = filter(b,a,dt);
subplot(4,1,4);
plot(t, retrieved);
title('Demodulated Signal (1904215)');
xlabel('Time Axis');
ylabel('Amplitude');