function levels = uelevels(B, sigma)
% UELEVELS  2^B bin centers or levels of B-bit DAC
%
% LEVELS = UELEVELS(B, SIGMA)
%    levels of B-bit DAC assuming the 2^B unit switched 
%    elements have the following properties:
%         mean value             1
%         std. dev.              sigma
%         are independent (i.e. no systematic errors)
%    first level is zero (no error)

% generate levels (values of switched elements)
N = 2^B;               % number of levels
elements = sigma * randn(N, 1) + 1;
levels = cumsum(elements);
