0% found this document useful (0 votes)
85 views3 pages

PCM Mod and Demodulation

This document describes the process of pulse code modulation (PCM) using MATLAB code. It involves sampling an analog signal, quantizing the sample values, encoding the quantized values into binary code, transmitting the binary code, and decoding the binary code back into the quantized values at the receiver to reconstruct the original signal. The MATLAB code provided samples an 8-level sinusoidal signal, quantizes it into 4-bit values, encodes the quantized values into a binary signal, and decodes/demodulates the binary signal back into the quantized values to display the reconstructed signal.

Uploaded by

madhusudhan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
85 views3 pages

PCM Mod and Demodulation

This document describes the process of pulse code modulation (PCM) using MATLAB code. It involves sampling an analog signal, quantizing the sample values, encoding the quantized values into binary code, transmitting the binary code, and decoding the binary code back into the quantized values at the receiver to reconstruct the original signal. The MATLAB code provided samples an 8-level sinusoidal signal, quantizes it into 4-bit values, encodes the quantized values into a binary signal, and decodes/demodulates the binary signal back into the quantized values to display the reconstructed signal.

Uploaded by

madhusudhan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

PCM (pulse code modulation)

clc;
close all;
clear all;
n=input('Enter n value for n-bit PCM system : ');
n1=input('Enter number of samples in a period : ');% n1 no of
samples have to be selected
L=2^n;
x=0:2*pi/n1:2*pi;
s=8*sin(x);
disp('sampled value is given by s');s;
subplot(3,1,1);
plot(s);
title('analog signal');
ylabel('Amplitude');
xlabel('Time');
%sampled signal
subplot(3,1,2);
stem(s);grid on;
title('sampled signal');
ylabel('Amplitude');
xlabel('Time');

vmax=8;
vmin=-vmax;
del=(vmax-vmin)/L
part=vmin:del:vmax;
code=vmin-(del/2):del:vmax+(del/2);
[ind,q]=quantiz(s,part,code);
1=length(ind);
2=length(q); % just not required
for i=1:11
if(ind(i)~=0)
ind(i)=ind(i)-1;
end
i=i+1;
end
disp('Quantized signal ind');ind;

subplot(3,1,3);
stem(q);grid on;
title('quantized signal');
ylabel('Amplitude');
xlabel('Time');
disp('Quantization level');

figure
code=de2bi(ind,'left-msb');
k=1;
for i=1:1
for j=1:n
coded(k)=code(i,j);
j=j+1;
k=k+1;
end
i=i+1;
end
subplot(2,1,1);grid on;
stairs(coded); % it’s a plot of PCM
axis([0 100 -2 3]);
title('encoded signal');
ylabel('Amplitude');
xlabel('Time');

qunt=reshape(coded,n,length(coded)/n);
index=bi2de(qunt','left-msb');
%q=del*index+vmin+(del/2)+1%
subplot(2,1,2);grid on;
plot(q);
title('Demodulated signal');
ylabel('Amplitude');
xlabel('Time');

You might also like