Created
December 12, 2020 02:19
-
-
Save Leovaldez42/cfa291b4efca92d63e7f4c81de8e8abf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clc; | |
msg = [];stuff = []; | |
n = input("Enter length of message "); | |
disp("Enter the message bits: "); | |
i = 1;j=1;count = 0; | |
while i<= n | |
msg(i)=input(''); | |
stuff(j)=msg(i); | |
if(msg(i)==1) | |
count=count+1; | |
elseif(msg(i) == 0) | |
count = 0; | |
end | |
if(count == 5) | |
j = j + 1; | |
stuff(j) = 0; | |
count = 0; | |
end | |
j = j + 1; | |
i = i + 1; | |
end | |
disp("Message entered :"); | |
disp(msg); | |
disp("Message after bit stuffing "); | |
disp(stuff); | |
des = []; | |
i=1;j=1;count=0; | |
while j <= n | |
if(stuff(i) == 1) | |
count = count + 1; | |
elseif(stuff(i) == 0) | |
count = 0; | |
end | |
des(j) = stuff(i); | |
if(count == 5) | |
i =i + 1; | |
count = 0; | |
end | |
j = j + 1; | |
i = i + 1; | |
end | |
disp("Message after Bit Unstuffing"); | |
disp(des); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment