You are on page 1of 4

http://www.pbtstudies.blogspot.

com

PULSE CODE MODULATION AND DIFFERENTIAL PULSE CODE MODULATION:

Matlab Coding:

PCM:

t=0:0.0005:20;
partition=-1:0.1:1;
codebook= -1:0.1:1.1;
x=sin(t);
[index,quants]=quantiz(x,partition,codebook);
subplot(3,1,1);
plot(t,x);
title('Message Signal');
subplot(3,1,2);
plot(t,quants);
title('Quantized Signal');
y=uencode(quants,3);
subplot(3,1,3);
plot(t,y);
title('PCM Signal');

DPCM:
predictor=[0,1];
partition=-1:0.1:.91;
codebook=-1:0.1:1;
t=0:0.07:10;
x=sin(3*t);
subplot(3,1,1);
plot(t,x);
title('Message Signal');
encodedx=dpcmenco(x, codebook, partition, predictor);
subplot(3,1,2);
plot(t,encodedx);
title('DPCM signal');
decodedx=dpcmdeco(encodedx,codebook,predictor);
subplot(3,1,3);
axis auto;
plot(t,decodedx);
title('Decoded Signal');

1
http://www.pbtstudies.blogspot.com

Message Signal
1

0.5

-0.5

-1
0 2 4 6 8 10 12 14 16 18 20

Quantized Signal
1

0.5

-0.5

-1
0 2 4 6 8 10 12 14 16 18 20

PCM Signal
8

0
0 2 4 6 8 10 12 14 16 18 20

2
http://www.pbtstudies.blogspot.com

Message Signal
1

0.5

-0.5

-1
0 1 2 3 4 5 6 7 8 9 10

DPCM signal
13

12

11

10

7
0 1 2 3 4 5 6 7 8 9 10

Decoded Signal
1

0.5

-0.5

-1
0 1 2 3 4 5 6 7 8 9 10

3
http://www.pbtstudies.blogspot.com

You might also like