Digital Signal Processing Reference
In-Depth Information
disp(
'
20*log10(k)
¼
>
'
);
k
¼
20*log10(k)
bits
¼
input(
'
input number of bits
¼
>
'
);
lg
¼
length(sig);
for x
¼
1:lg
[Index(x) pq]
¼
biquant(bits, -5,5, sig(x)); % Output quantized index
end
% transmitted
% received
for x
1:lg
qsig(x)
¼
¼
biqtdec(bits, -5,5, Index(x));
% Recover the quantized value
end
qerr
¼
sig-qsig;
% Calculate the quantized error
subplot(3,1,1);plot(t,sig);
ylabel(
'
Original speech
'
);title(
'
we.dat: we
'
);
subplot(3,1,2);stairs(t, qsig);grid
ylabel(
'
Quantized speech
'
)
subplot(3,1,3);stairs(t, qerr);grid
ylabel(
'
Quantized error
'
)
xlabel(
'
Time (sec.)
'
);axis([0 0.25 -1 1]);
disp(
'
signal to noise ratio due to quantization noise
'
)
snr(sig,qsig);
% Signal to ratio in dB:
sig
¼
original signal vector,
% qsig
¼
quantized signal vector
we.dat: we
5
0
-5
0
0.05
0.1
0.15
0.2
0.25
5
0
-5
0
0.05
0.1
0.15
0.2
0.25
1
0
-1
0
0.05
0.1
0.15
0.2
0.25
Time (s ec . )
FIGURE 2.34
Original speech, quantized speech using the 4-bit bipolar quantizer, and quantization error.
Search WWH ::
Custom Search