Pulse Code Modulation and Demodulation

185 views (last 30 days)
Saad Rana
Saad Rana on 27 Dec 2020
Answered: Darel on 3 Jun 2022
I have written a code to do Pulse Code Modulation but I am unable to retrieve the message signal back. Can someone please help me write demodulation code.
Here is what I have written for modulation
time = 0:0.0001:20;
const = input('Enter Bit Depth of PCM Coding:');
part = -1:0.1:1;
codebook = -1:0.1:1.1;
msg = sin(time);
[indx,quants] = quantiz(msg,part,codebook);
subplot(3,1,1);
plot(time,msg);
title('Message Signal');
subplot(3,1,2);
plot(time,quants);
title('Quantized Signal');
y = uencode(quants,const);
ybin = dec2bin(y,const);
subplot(3,1,3);
plot(time,y);
title('PCM PLOT');
How can I convert back the modulated signal to original.

Accepted Answer

Darel
Darel on 3 Jun 2022
If the bit depth is reasonably large (say const = 8), then you can get back the uencoded signal with udecode:
newquants = udecode(y, const)
max(abs(quants(:) - newquants(:)))
One other thing about this code is that the quantiz function could be configured better. The "codebook" entry for quantiz provides the values assigned to represent input numbers that fall within each quantization bin. So you probably want to select values that represent the center of the bins, not the endpoints. Note also that the first and last entries represent values that fall outside the total range. So a better setting for "codebook" would be
codebook = [-10, -.95:0.1:.95, 10];

More Answers (1)

Asmita Jangam
Asmita Jangam on 8 May 2021
c=input('Enter Bit Depth Of PCM Coding:');

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by