Digital Signal Processing Reference
In-Depth Information
EXAMPLE 2.13
Given a sinusoidal waveform with a frequency of 100 Hz,
xðtÞ¼4:5$sinð2p 100tÞ
sampled at 8,000 Hz,
a. write a MATLAB program to quantize xðtÞ using 4 bits to obtain and plot the quantized signal x q , assuming the
signal range is between 5 and 5 volts;
b. calculate the SNR due to quantization.
Solution:
a. Program 2.1. MATLAB program for Example 2.13.
%Example 2.13
clear all; close all
disp( ' Generate 0.02-second sine wave of 100 Hz and Vp ¼ 5 ' );
fs ¼ 8000;
% Sampling rate
T ¼ 1/fs;
% Sampling interval
t ¼ 0:T:0.02;
% Duration of 0.02 second
sig ¼ 4.5*sin(2*pi*100*t);
% Generate sinusoids
bits ¼ input( ' input number of bits ¼ > ' );
lg ¼ length(sig);
% Length of signal vector sig
for x
1:lg
[Index(x) pq]
¼
¼
biquant(bits, -5,5, sig(x));
% Output quantized index
5
4
3
2
1
0
-1
-2
-3
-4
-5
0
0.002
0.004
0.006
0.008
0.01
0.012
0.014
0.016
0.018
0.02
Time (s ec . )
FIGURE 2.33
Comparison of the quantized signal and the original signal.
Search WWH ::




Custom Search