crcgen1.m

来自「matlab编程及simulink实现的m_s文件程序」· M 代码 · 共 14 行

M
14
字号

function crc_data=crcgen1(data)
% k=4; % values of interest are 138, 113, 101, 87, 84, and 80
% data=randint(1,k,2)
poly=[ 1 1 1 0 1 ]; % x^4+x^3 + x^2 + 1
% poly = [1 1 1 0 1]; % x^4+x^3 + x^2 + 1
% Build the CRC with gfdeconv
[q,r]=gfdeconv(fliplr([data zeros(1,length(poly)-1)]),fliplr(poly));
r=fliplr(r); % change to descending powers
if length(r)<length(poly)-1
   r=[zeros(1,length(poly)-1-length(r)),r];
end
crc_data=[data r]; % add the remainder

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?