资源简介
已经编译通过~
CRC算法原理与实现代码
产品简介:CRC算法原理与实现代码
产品详细介绍:
CRC 代数学的一般性算法
在代数编码理论中,将一个码组表示为一个多项式,码组中各码元当作多项式的系数。
代码片段和文件信息
function [ output ] = crc_add( input crc_no )
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% written by Wang Meifang on 24th April 2008
% Email: mflltt@126.com
% the function is proposed for adding crc bits to the input sequence
% input: the input information bits a column vector
% crc_no: the number of the adding crc bits such as 38121624
% output: the output information+crc bits a column vector
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% the length of input
k = size(input2);
generator = zeros(1crc_no+1);
output = zeros(1k+crc_no);
switch crc_no
case 3
generator = [1 0 1 1];
case 8
generator = [1 1 0 0 1 1 0 1 1]; %D^8+D^7+D^4+D^3+D+1
case 12
generator = [1 1 0 0 0 0 0 0 0 1 1 1 1]; %D^12+D^11+D^3+D^2+D+1
case 16
generator = [1 0 0 0 1 0 0 0 0 0 0 1 0 0 0 0 1]; %D^16+D^12+D^5+1
case 24
generator = [1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 0 0 0 1 1]; %D^24+D^23+d^6+D^5+D+1
otherwise
fprintf(‘\nPlease the number of crc bits should be 8 12 16 24\n‘);
end
output(1:k)=input;
for ii = 1:k
if(output(1) == 1)
output(1:crc_no+1) = mod((output(1:crc_no+1)+generator)2);
end
output = [output(2:end) output(1)];
end
output = [input output(1:crc_no)];
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1286 2008-04-24 13:14 CRC\crc_add.m
文件 1429 2008-04-24 13:14 CRC\crc_check.m
文件 1524 2007-04-11 10:38 CRC\CRC算法原理与实现代码-c.txt
文件 232 2008-04-24 13:14 CRC\test.m
目录 0 2008-04-24 13:14 CRC
----------- --------- ---------- ----- ----
4471 5
评论
共有 条评论