1. Why does 1 0 1 0 occur?
x = Original input signal
y = Reconstructed signal (staircase approximation)
if x(i) >= y(i-1)
dm(i) = 1;
y(i) = y(i-1) + delta;
else
dm(i) = 0;
y(i) = y(i-1) - delta;
endSuppose:
Input value = 0.05
Previous reconstructed value = 0.04
Step size = 0.1
The next reconstructed value becomes 0.14.
Now the input (0.05) is less than 0.14, so the next bit becomes 0.
The reconstructed value becomes 0.04 again.
Now the input is greater than or equal to 0.04, so the next bit becomes 1.
Therefore, the pattern becomes:
1 0 1 0 1 0 1 0
This is called granular noise.
2. How to get longer sequences of 1s and 0s?
You need to reduce the step size.
In your MATLAB code, change:
delta = 0.1;to:
delta = 0.02;You can also try:
delta = 0.01;With a smaller step size, the staircase can follow the gradual changes more smoothly, although too small a step size can cause slope overload.
3. Important: Understand the bit patterns
111111...→ Reconstructed signal keeps increasing.000000...→ Reconstructed signal keeps decreasing.101010...→ Reconstructed signal oscillates around the input (granular noise).
4. One more important point
Your expectation of:
111111...111000000...000111111...
is reasonable when the input changes sufficiently fast relative to the step size.
But DM does not necessarily produce long runs of identical bits. It depends on:
Input signal frequency
Sampling frequency
Step size (Δ)
First try delta = 0.02 and observe the modulated and demodulated signals. You should see a change in the bit pattern.
MATLAB Code for Delta Modulation (DM) and Demodulation
clc;
clear;
close all;
% Generate input signal
t = 0:0.01:2;
x = sin(2*pi*2*t);
% Initialize parameters
delta = 0.1;
y = zeros(size(x));
dm = zeros(size(x));
% Delta Modulation
for i = 2:length(x)
if x(i) >= y(i-1)
dm(i) = 1;
y(i) = y(i-1) + delta;
else
dm(i) = 0;
y(i) = y(i-1) - delta;
end
end
% Delta Demodulation
demod = zeros(size(x));
for i = 2:length(dm)
if dm(i) == 1
demod(i) = demod(i-1) + delta;
else
demod(i) = demod(i-1) - delta;
end
end
% Plotting
subplot(3,1,1);
plot(t,x,'b','LineWidth',1.5);
title('Original Signal');
xlabel('Time');
ylabel('Amplitude');
grid on;
subplot(3,1,2);
stairs(t,dm,'r');
title('Delta Modulated Signal');
xlabel('Time');
ylabel('DM Bits');
grid on;
subplot(3,1,3);
plot(t,demod,'g','LineWidth',1.5);
title('Demodulated Signal');
xlabel('Time');
ylabel('Amplitude');
grid on;