You are on page 1of 1

clc;

clear;
close all;
t = linspace(0,20,10000);
bitdepth = 8;
part = -1:0.1:2;
codebook = -1:0.1:2.1;
msg = sin(t)/2;
[~,quants] = quantiz(msg,part,codebook);
y = uencode(quants,bitdepth);
subplot(3,1,1);
plot(t,msg);
xlabel('Time')
ylabel('Signal')
subplot(3,1,2);
plot(t,quants);
xlabel('Time')
ylabel('Quantized')
%ybin=dec2bin(y,bitdepth);
subplot(3,1,3);
plot(t,y);
xlabel('Time')
ylabel('PCM Encoded')

You might also like