📄 crc16.m
字号:
%Variable initialization
gx=[1 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 1];
x=ceil(rand(1,1000)*2-1);
x=[x zeros(1,16)];
%Mathematically, the CRC value corresponding to a given frame
%is defined by the following procedure.
% The first 16 bits of the input bit sequence are complemented.
rx=bitcmp(x(1:16),1);
% The bit sequence is divided by G(x), producing a remainder
% R(x) of degree <= 15.
for i=1:1000
nm=[rx x(i+16)];
if nm(1)==1
rx=xor(nm(2:17),gx(2:17));
else
rx=nm(2:17);
end
end
rx=bitcmp(rx,1);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -