444 CHAPTER 7: Sampling Theory
7.4.3 Sampling, Quantizing, and Coding with MATLAB
The conversion of an analog signal into a digital signal consists of three steps: sampling, quantization,
and coding. These are the three operations an ADC does. To illustrate them consider a sinusoid
x(t)=4 cos( 2 πt). Its sampling period, according to the Nyquist sampling rate condition, isTs≤π/max=0.5 sec/sampleas the maximum frequency ofx(t)ismax= 2 π. We letTs=0.01 (sec/sample) to obtain a sam-
pled signalxs(nTs)=4 cos( 2 πnTs)=4 cos( 2 πn/ 100 ), a discrete sinusoid of period 100. The following
script is used to get the sampledx[n] and the quantizedxq[n] signals and the quantization errorε[n]
(see Figure 7.13).0 0.5 1− 4− 2024t (sec)x(t)0 50 100− 4− 2024nx[n]Sampled signal(a) (b)(c) (d)0 50 100− 4− 2024Quantized signaln0 50 10001234e[n]nxq[n
]FIGURE 7.13
(a) Sinusoid, (b) sampled sinusoid usingTs=0.01, (c) quantized sinusoid using four levels, and (d) quantization
error.