Last active
December 11, 2020 17:51
-
-
Save Leovaldez42/acce32717e1d74491e2a031c3a2cd36a 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=input('Input Message sequence :'); %msg=[1 0 0 1 0 0]; | |
poly=input('Input Generator Polynomial :'); %poly=[1 1 0 1]; | |
[M,N] = size(poly); | |
mseg = [msg zeros(1,N-1)]; | |
[q,r] = deconv(mseg, poly); | |
r=abs(r); | |
for i=1:length(r) | |
a=r(i); | |
if ( mod(a,2)== 0 ) | |
r(i)=0; | |
else | |
r(i)=1; | |
end | |
end | |
crc=r(length(msg)+1:end); | |
disp(crc); | |
frame = bitor(mseg,r); | |
disp(frame); | |
remsg = input("Enter the received message sequence:"); | |
[a,b] = deconv(remsg,poly); | |
if mod(b,2)==0 | |
flag=0; | |
else | |
flag=1; | |
end | |
if flag==1 | |
disp("The received bits stream is erroneous."); | |
else | |
disp("There is no error in received bit stream."); | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment