Created
November 27, 2016 03:24
-
-
Save jsantanders/c183d7dcb0e2e1749fec2d3b15320cb2 to your computer and use it in GitHub Desktop.
cyclic redundancy check MATLAB implementation
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
function CRC = mod2 (word, G) | |
m = zeros (1,length(G)); | |
wordext = [word m]; | |
while length (G) <= length (wordext) | |
for i = 1:length(G) | |
wordext(i) = xor(wordext(i),G(i)); | |
end | |
while wordext(1) == 0 | |
wordext = wordext(2:end); | |
if not (wordext) | |
wordext = 0; | |
break | |
end | |
end | |
end | |
CRC = [zeros(1:length(G)-length(wordext)) wordext]; | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment