0% found this document useful (0 votes)
52 views5 pages

Generating A PCM Signal Investigate The Magnitude Spectrum of The PCM Signal

The document describes an experiment on pulse code modulation (PCM) using MATLAB. The objectives are to generate a PCM signal and investigate its magnitude spectrum. The experiment uses a computer and MATLAB software. The code samples an analog signal, quantizes it, encodes the quantized samples into binary code, and decodes and dequantizes the encoded signal back to its original form. The output shows the input-output signals of the PCM process and the simulation results.

Uploaded by

towhidul
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)
52 views5 pages

Generating A PCM Signal Investigate The Magnitude Spectrum of The PCM Signal

The document describes an experiment on pulse code modulation (PCM) using MATLAB. The objectives are to generate a PCM signal and investigate its magnitude spectrum. The experiment uses a computer and MATLAB software. The code samples an analog signal, quantizes it, encodes the quantized samples into binary code, and decodes and dequantizes the encoded signal back to its original form. The output shows the input-output signals of the PCM process and the simulation results.

Uploaded by

towhidul
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/ 5

Experiment no: 04

Experiment name: Experiment on pulse code modulation using matlab software.

Objective:
 Generating a pcm signal
 Investigate the magnitude spectrum of the pcm signal

Equipment:
 A computer
 Matlab software

Code:

clc;
close all;
clear all;
n=input('Enter n value for n-bit PCM system:');
m=input('Enter number of sample in a period:');
L=2^n;
X=0:2*pi/m:4*pi;
S=8*sin(X);
subplot(3,1,1);
plot(S);
grid on;
title('Analog signal');
xlabel('Time');
ylabel('Amplitude');
subplot(3,1,2);
stem(S);
grid on;
title('Sampled signal');
xlabel('Time');
ylabel('Amplitude');
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);
A=length(ind);
B=length(q);
for i=1:A
if(ind(i)~=0)
ind(i)=ind(i)-1;
end
i=i+1;
end

for i=1:B
if(q(i)==vmin-(del/2))
q(i)=vmin+(del/2);
end
end
subplot(3,1,3);

stem(q);
grid on;
title('quantize signal');
xlabel('Time');
ylabel('Amplitude');
figure;
code=de2bi(ind,'left-msb');
k=1;
for i=1:A
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);
axis([0 100 -2 3]);
title('Encoded signal');
xlabel('Time');
ylabel('Amplitude');
grid on;
qunt=reshape(coded,n,length(coded)/n);
index=de2bi(qunt','left-msb');
q=del*index+vmin+(del/2);
subplot(2,1,2);
grid on;
title('Demodulated signal');
xlabel('Time');
ylabel('Amplitude');

output:
Fig: The input-output of PCM

Simulation Process of PCM :


Fig: output signal of PCM from simulation.

Discussion:

You might also like