Example2 Comm w4
Example2 Comm w4
clc;
clear all;
Sample this analog signal each 0.05 s and quantize using 3 bits.
n=2^3
n = 8
t = 1×21
0 0.0500 0.1000 0.1500 0.2000 0.2500 0.3000 0.3500
sig = 1×21
0 0.3059 0.5819 0.8009 0.9415 0.9900 0.9415 0.8009
plot(t,sig)
1
Partion values between -1 and +1 and space 2/(n-1)
partition = 1×8
-1.0000 -0.7143 -0.4286 -0.1429 0.1429 0.4286 0.7143 1.0000
codebook = 1×9
-1.0000 -0.7500 -0.5000 -0.2500 0 0.2500 0.5000 0.7500
quants = 1×21
0 0.2500 0.5000 0.7500 0.7500 0.7500 0.7500 0.7500
plot(t,sig,'x',t,quants,'.')
legend('Original signal','Quantized signal');
axis([-0.1 1.1 -1.2 1.1])
2
Binary Codes
bindat=dec2bin(index)