1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
| t=0:1/500:1-1/500;
U=sin(2*pi*5.00*t);
Umax=1; % Set maximum voltage, for which max ADC code is reached
bits=3; % ADC resolution
Uq=double(uencode(U,bits,Umax,'signed'))/(2^(bits-1))*(Umax);
figure;
subplot 211
plot(t,U), hold on, stem(t,Uq);
xlabel('t, s') , ylabel('Magnitude, V');
legend('U','U_{quantized}');
subplot 212
plot(t,U-Uq);
legend('Quantization Error');
xlabel('t, s') , ylabel('Magnitude, V');
|