crc_16.asv

来自「CRC-16的编解码程序和仿真结果。统计了漏检概率随错误比特数目的曲线。」· ASV 代码 · 共 77 行

ASV
77
字号
clear;
clc;
%仿真CRC-16的漏检概率
p='11000000000000101';
k=16;
n=k+16;
d='1111100000101010';
%d='111110000010101011111111';
D=bin2dec(d);
P_CRC=0;
num


%加噪声
pb=0.1;  %误码率

for k1=1:n
    for k2=k1+1:n
        for k3=k2+1:n
        for k4=k3+1:n
       % for k5=k4+1:n
       % for k6=k5+1:n
        t=CRC_send(D,p);

        if t(k1)=='1'
            t(k1)='0';
        else
            t(k1)='1';
        end
        
        if t(k2)=='1'
            t(k2)='0';
        else
            t(k2)='1';
        end
        
        if t(k3)=='1'
            t(k3)='0';
        else
            t(k3)='1';
        end
        
        if t(k4)=='1'
            t(k4)='0';
        else
            t(k4)='1';
        end
        
        
        cont=4;           %%%%%%%
        rt=t;
 
%接收检错
        [q,l,rr,m]=mod2_div(rt,n,p,length(p));
        RR=bin2dec(rr);
        
            if RR==0
                num=num+1;
                P_CRC=P_CRC+(pb^cont)*(1-pb)^(n-cont);
            end
        end
        end   
        %end               %%%%%%%
        %end
    end
end

format short e;
P_CRC







⌨️ 快捷键说明

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