Simulation of Pulse Code Modulation and Demodulation: All All
Simulation of Pulse Code Modulation and Demodulation: All All
clc;
clear all;
close all;
%Signal amplitude and Frequency
a=1;
f=2;
t=0:0.01:1;
x=a*sin(2*pi*f*t)+a;
%plot message signal
subplot(2,1,1);
plot(t,x);
title('Input signal');
xlabel('time');
ylabel('amplitude');
%plot sampled signal
subplot(2,1,2);
stem(t,x);
title('Sampled Signal');
xlabel('time');
ylabel('amplitude');
%modulation process
partition=[0:0.1:2*a];
codebook=[0:0.1:((2*a)+0.1)];
[index,d]=quantiz(x,partition,codebook);
%plot quantized DM signal
figure;
subplot(2,1,1);
stairs(t,d);
title('Quantized Signal');
xlabel('time');
ylabel('amplitude');
MODEL GRAPH:
Input signal
2
amplitude
1.5
0.5
0.1
0.2
0.3
0.4
0.5
time
0.6
0.7
0.8
0.9
0.6
0.7
0.8
0.9
Sampled Signal
2
amplitude
1.5
0.5
0.1
0.2
0.3
0.4
0.5
time
Quantized Signal
2
amplitude
1.5
0.5
0.1
0.2
0.3
0.4
0.5
time
0.6
0.7
0.8
0.9
0.6
0.7
0.8
0.9
Reconstructed Signal
2
amplitude
1.5
0.5
-0.5
0.1
0.2
0.3
0.4
0.5
time
PCM output
01,01,01,01,01,01,01,01,01,10,10,10,10,10,10,10,10,01,01,01,01,01,01,01,01,01,00,00,00,
00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,00,01,01,01,01,01,01,01,01,
01,10,10,10,10,10,10,10,10,01,01,01,01,01,01,01,01,01,00,00,00,00,00,00,00,00,00,00,00,
00, 00,00,00,00,00,00,00,00,00,00,00,00,01