Digital Signal Processing Reference
In-Depth Information
% [BinMat,Err] = LVSuccessApp(7.5*[sin(0.5*pi*[0:1/18:1])]+7.5,4,1);
BinMat = zeros(length(DecNum),MaxBits);
DecOutMat = zeros(1,length(DecNum));
if LSBBias==0; xDecNum = DecNum;
else; xDecNum = DecNum + 0.5; end
for DecNumCtr = 1:1:length(DecNum)
BinTstWord = zeros(1,MaxBits);
for ctr = 1:1:MaxBits; BinTstWord(1,ctr) = 1;
DecEquivCurrBinTstWord = LVBinary2DecimalVec(BinTstWord);
diff = xDecNum(DecNumCtr) - DecEquivCurrBinTstWord;
if diff < 0; BinTstWord(1,ctr) = 0;
elseif diff==0; break; else; end
end
BinMat(DecNumCtr,:) = BinTstWord;
DecOutMat(1,DecNumCtr) = LVBinary2DecimalVec(BinTstWord);
Err = DecNum-DecOutMat;
end
figure(78); clf; subplot(211); ldn = length(DecNum);
xvec = 0:1:ldn-1; hold on; plot(xvec,DecNum,'b:');
plot(xvec,DecNum,'bo'); stairs(xvec,DecOutMat,'r');
xlabel('(a) Sample'); ylabel('Amplitude')
subplot(212); stairs(xvec,Err,'k');
xlabel('(b) Sample'); ylabel('Error')
The call
[BinMat,Err] = LVSuccessApp(7.5*[sin(0.5*pi*[0:1/18:1])]+7.5,4,0);
results in Fig. 3.13, in which the quantized values are plotted in stairstep fashion rather than as discrete
points. Note that the error is positive, and has a maximum amplitude of about 1.0, i.e., one LSB.
The following call specifies that prior to conversion, 0.5LSB (i.e., 0.5 in this case since the LSB is
1.0) be added to the signal:
[BinMat,Err] = LVSuccessApp(7.5*[sin(0.5*pi*[0:1/18:1])]+7.5,4,1);
The result is shown in Fig. 3.14, in which it can be seen that the error is both positive and negative,
but does not exceed 0.5, i.e., one-half LSB.
3.11
CLIPPING
The call
[BinMat] = LVSuccessApp(10*[sin(2*pi*[0:1/18:1])]+10,4,1);
results in Fig. 3.15. As only four bits were specified for the quantization, we can only represent the numbers
0-15, whereas the input waveform ranges in value from 0 to 20. The algorithm outputs its maximum
value of 15 (binary [1,1,1,1]) for signal values of 14.5 and higher; the output is said to be clipped since
graphically it appears that its upper portions (samples 2 through (7) have simply been cut or clipped off.
Search WWH ::




Custom Search