Skip to content

Instantly share code, notes, and snippets.

@Leovaldez42
Created December 12, 2020 02:19
Show Gist options
  • Save Leovaldez42/cfa291b4efca92d63e7f4c81de8e8abf to your computer and use it in GitHub Desktop.
Save Leovaldez42/cfa291b4efca92d63e7f4c81de8e8abf to your computer and use it in GitHub Desktop.
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