221902001-Lab Report 7
221902001-Lab Report 7
Lab Report NO # 07
Course Title: Data Communication Lab
Course Code: CSE 308. Section: 221- D7.
Manchester.
Student Details
Student Name ID
Hasnat Zamil 221902001
Procedure
Implementation
bits = [1 0 0 1 0 1 1 0];
bitrate = 1;
n = 1000;
T = length(bits)/bitrate;
N = n*length(bits);
dt = T/N;
t = 0:dt:T;
x = zeros(1,length(t));
lastbit = 1;
for i=1:length(bits)
if bits(i)==0
x((i-1)*n+1:(i-1)*n+n/2) = -lastbit;
x((i-1)*n+n/2:i*n) = lastbit;
else
x((i-1)*n+1:(i-1)*n+n/2) = lastbit;
x((i-1)*n+n/2:i*n) = -lastbit;
lastbit = -lastbit;
end
end
plot(t, x, 'Linewidth', 3);
counter = 0;
lastbit = 1;
for i = 1:length(t)
if t(i)>counter
counter = counter + 1;
if x(i)==lastbit
result(counter) = 1;
lastbit = -lastbit;
else result(counter) = 0;
end
end
end
disp('Differential Manchester Decoding:');
disp(result);
Output
Conclusion
In summary, this code first encodes binary data using Differential Manchester
Encoding, then plots the encoded signal, and finally decodes the signal back into
binary data using Differential Manchester Decoding.