Professional Documents
Culture Documents
>>cd d:\sc\functiisc
>>start
5
The sampling frequency is set to 8 kHz.
A. Uniform quantizing
Pulse code modulation (PCM) is an analog to digital conversion technique which includes sampling, quantizing
and encoding. Since the amplitude of an analog signal has a continuous range of variation, the sample’s
amplitude may have an infinite number of possible values. Since it’s not possible to assign each amplitude a
unique codeword, the quantizing is an approximation of sample’s amplitudes with some given values.
Table 1
The values into the second column are the quantizing levels.
Generate an 8-element vector x which contains the amplitudes of a sampled analog signal:
>>x=[0.8, 0.6, 0.2, -0.4, 0.1, -0.9, -0.3, 0.7];
After quantizing is done, the encoder assigns each quantizing level a unique 2-bit symbol. For example, it can
assign the 00 symbol to the quantizing level corresponding to the lowest voltage. With the voltage increase, the
equivalent decimal representation of the assigned 2-bit symbol increases with one unit. This procedure is
referred as the natural binary encoding.
Generate the samples of a sine waveform, with 1 V amplitude, 20 Hz frequency and 8 kHz sampling frequency:
>>x=sin(2*pi*20*[1:400]/8000);
There are two types of distortions generated by quantizing: overload distortion and quantizing noise. When the
input signal amplitude exceeds the input range of the quantizer, the overload distortion occurs. The quantizer
output will be limited to the maximum or minimum quantizing levels.
If the amplitude of the input sine waveform is 0.49 V, plot this signal together with the 3-bit uniform quantizer
output:
>>a=0.49;
>>clf, waveplot(a*x), hold on, waveplot(quantize(a*x, 3))
Increase now the amplitude of the signal and repeat the procedure for a=1.49.
To avoid limiting, the signal has to be adapted to the quantizer input range.
The quantizing noise is the difference between the input and the output of the quantizer:
>>xq=quantize(x, N); xe=x-xq;
>>clf, waveplot(xe)
N 2 3 4 5
max(abs(xe))
Table 2
Generate the following sequence and plot it’s power spectral density function:
>>x=sin(2*pi*512*[1:2048]/8000);
>>psd(x)
Generate the uniform quantizer output and evaluate the variance of the quantizing noise:
>>xq=quantize(x, N);
>>psd(xq)
>>sq2=10*log10(var(x-xq))
where N = { 2, 3, 4, 5, 6}.
N 2 3 4 5 6
σ q [dB]
2
Table 3
Assuming that the amplitude of the quantization noise is uniformly distributed in [q/2, q/2] V interval, where q
is the quantizing step, the variance of quantization noise is σ q [dB] = −(4.77 + 6.02 * N) [dB].
2
Compare the results in Table 3 with the results obtained using this formula.