To Convert The Analog Signal Into Digital Pulses
To Convert The Analog Signal Into Digital Pulses
To Convert The Analog Signal Into Digital Pulses
4. Solve for the sampled value, V, at each sampling instant: We have 11 sampling instants, so the
sampled values will be: V1 = -1 V2 = -0.5 V3 = 0 V4 = 0.5 V5 = 1 V6 = 0.5 V7 = 0 V8 = -0.5 V9 = -1
V10 = -0.5 V11 = 0
5. Solve for step-size: The range of the analog signal is -1 to +1 V, and we are using 2 bits for
quantization. Therefore, the step-size is given by: Step-size = (max range of analog signal) /
(number of quantization levels - 1) Step-size = 2 / (2^2 - 1) Step-size = 0.67
6. Solve for the Index and quantized value: The quantized value is obtained by rounding the
sampled value to the nearest quantization level, and the index is obtained by mapping the
quantized value to its binary representation.
-1 -1 00
-0.5 -1 00
0 0 01
0.5 1 10
1 1 10
0.5 1 10
0 0 01
-0.5 -1 00
-1 -1 00
-0.5 -1 00
0 0 01
7. Show on the graph the quantized discrete pulses: To graph the quantized discrete pulses, we
can use a step function with vertical steps at each sampling instant. The height of each step
represents the quantized value obtained from the table above.
% Define parameters
x = A*sin(2*pi*f*t);
Ts = 1/f;
t_sampled = 0:Ts:(1/1000);
x_sampled = A*sin(2*pi*f*t_sampled);
% Plot signals
subplot(4,1,1)
plot(t,x,'b')
title('Analog Signal')
xlabel('Time (s)')
ylabel('Amplitude (V)')
subplot(4,1,2)
stem(t_sampled,x_sampled,'r','Marker','none')
title('Sampled Signal')
xlabel('Time (s)')
ylabel('Amplitude (V)')
subplot(4,1,3)
stairs(t_sampled,x_quantized,'g')
title('Quantized Signal')
xlabel('Time (s)')
ylabel('Amplitude (V)')
subplot(4,1,4)
stairs(t_sampled,x_encoded,'m')
title('Encoded Signal')
xlabel('Time (s)')
ylabel('Binary Code')
% Helper functions
x_quantized = round(x/q)*q;
x_quantized(x_quantized>max(levels)) = max(levels);
x_quantized(x_quantized<min(levels)) = min(levels);
end
x_encoded = zeros(size(x_quantized));
for i = 1:length(levels)
end
end