0% found this document useful (0 votes)
25 views2 pages

Lab Tasks 10

This document contains the code to implement a digital signal processing task involving quantization of an analog signal using pulse code modulation (PCM). The code samples an analog signal, quantizes it using an n-bit uniform quantizer, encodes the quantized samples, and then decodes and reconstructs the signal. Key steps include: 1) defining the analog signal, quantization levels, and encoding; 2) quantizing and encoding the sampled signal; 3) decoding the encoded signal and reconstructing the quantized signal. Plots are generated to visualize the analog, quantized, encoded, and reconstructed signals.

Uploaded by

Afaq Khaliq
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)
25 views2 pages

Lab Tasks 10

This document contains the code to implement a digital signal processing task involving quantization of an analog signal using pulse code modulation (PCM). The code samples an analog signal, quantizes it using an n-bit uniform quantizer, encodes the quantized samples, and then decodes and reconstructs the signal. Key steps include: 1) defining the analog signal, quantization levels, and encoding; 2) quantizing and encoding the sampled signal; 3) decoding the encoded signal and reconstructing the quantized signal. Plots are generated to visualize the analog, quantized, encoded, and reconstructed signals.

Uploaded by

Afaq Khaliq
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/ 2

Lab Task | 10

Task 1:
clc, close all, clear all; if(q(i)==vmin-(del/2))
n=input('Enter n value for n- q(i)=vmin+(del/2);
bit PCM system : '); end
n1=input('Enter number of end
samples in a period : '); subplot(3,1,3);
L=2^n; stem(q);grid on;
x=0:2*pi/n1:4*pi; title('Quantized Signal');
s=8*sin(x); ylabel('Amplitude--->');
subplot(3,1,1); xlabel('Time--->');
plot(s); figure
title('Analog Signal'); code=de2bi(ind,'left-msb');
ylabel('Amplitude--->'); k=1;
xlabel('Time--->'); for i=1:l1
subplot(3,1,2); for j=1:n
stem(s);grid on; coded(k)=code(i,j);
title('Sampled Sinal'); j=j+1;
ylabel('Amplitude--->'); k=k+1;
xlabel('Time--->'); end
vmax=8; i=i+1;
vmin=-vmax; end
del=(vmax-vmin)/L; subplot(2,1,1); grid on;
part=vmin:del:vmax; stairs(coded);
code=vmin-(del/2):del:vmax+ axis([0 100 -2 3]); title('Encoded
(del/2); Signal');
[ind,q]=quantiz(s,part,code); ylabel('Amplitude--->');
l1=length(ind); xlabel('Time--->');
l2=length(q); qunt=reshape(coded,n,length(coded)/n);
for i=1:l1 index=bi2de(qunt','left-msb');
if(ind(i)~=0) q=del*index+vmin+(del/2);
ind(i)=ind(i)-1; subplot(2,1,2); grid on;
end plot(q);
i=i+1; title('Demodulated Signal');
end ylabel('Amplitude--->');
for i=1:l2 xlabel('Time--->');
Lab Task | 10

Result:

You might also like