02.10.2019 Views

UploadFile_6417

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Analysis of A/D Quantization Noise 541<br />

function [H1,H2,Q, estat] = StatModelR(xn,B,N);<br />

% Statistical Model (Rounding) for A/D Quantization error and its Distribution<br />

% ------------- -------------------------------------------------------------<br />

% [H1,H2,Q] = StatModelR(xn,B,N);<br />

% OUT: H1 = Normalized histogram of e1<br />

% H2 = Normalized histogram of e2<br />

% Q = Normalized histogram bins<br />

% estat = row vector: [[e1avg,e1std,e2avg,e2std]<br />

% IN: B = bits to quantize<br />

% N = number of samples of x(n)<br />

% xn = samples of the sequence<br />

% Plot variables<br />

bM = 7; DbM = 2^bM;<br />

% bin parameter<br />

M = round((DbM)/2);<br />

% Half number of bins<br />

bins = [-M+0.5:1:M-0.5];<br />

% Bin values from -M to M<br />

Q = bins/(DbM);<br />

% Normalized bins<br />

% Quantization error analysis<br />

xq = (round(xn*(2^B)))/(2^B);<br />

% Quantized to B bits<br />

e1 = xq-xn; clear xn xq;<br />

% Quantization error<br />

e2 = 0.5*(e1(1:N-1)+e1(2:N));<br />

% Average of two adj errors<br />

e1avg = mean(e1); e1std = std(e1); % Mean & std dev of the error e1<br />

e2avg = mean(e2); e2std = std(e2); % Mean & std dev of the error e2<br />

estat = [e1avg,e1std,e2avg,e2std];<br />

% Probability distribution of e1<br />

e1 = floor(e1*(2^(B+bM))); % Normalized e1 (int between -M & M)<br />

e1 = sort([e1,-M-1:1:M]); %<br />

H1 = diff(find(diff(e1)))-1; clear e1; % Error histogram<br />

if length(H1) == DbM+1<br />

H1(DbM) = H1(DbM)+H1(DbM+1);<br />

H1 = H1(1:DbM);<br />

end<br />

H1 = H1/N;<br />

% Normalized histogram<br />

% Probability distribution of e2<br />

e2 = floor(e2*(2^(B+bM))); % Normalized e2 (int between -M & M)<br />

e2 = sort([e2,-M-1:1:M]); %<br />

H2 = diff(find(diff(e2)))-1; clear e2; % Error histogram<br />

if length(H2) == DbM+1<br />

H2(DbM) = H2(DbM)+H2(DbM+1);<br />

H2 = H2(1:DbM);<br />

end<br />

H2 = H2/N;<br />

% Normalized histogram<br />

To validate the model assumptions, we consider the following two examples.<br />

In the first example an aperiodic sinusoidal sequence is quantized<br />

to B bits, and in the second example a random sequence is quantized to B<br />

bits. The resulting quantization errors are analyzed for their distribution<br />

properties and for their sample independence for various values of B.<br />

Copyright 2010 Cengage Learning. All Rights Reserved. May not be copied, scanned, or duplicated, in whole or in part. Due to electronic rights, some third party content may be suppressed from the eBook and/or eChapter(s).<br />

Editorial review has deemed that any suppressed content does not materially affect the overall learning experience. Cengage Learning reserves the right to remove additional content at any time if subsequent rights restrictions require it.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!