(7,4)线性分组码matlab仿真(包含纠错部分代码)

clc
clear all
%%%%%%%%生成初始序列%%%%%%%
SignNum = 100;  %信息长度
genmat=[1 0 0 0 1 1 1;0 1 0 0 1 1 0;0 0 1 0 1 0 1;0 0 0 1 0 1 1];
Length = SignNum ;  %原始码序列长度
OrigiSeq=(sign(randn(1,SignNum))+1)/2;    %产生原始的0或1信息序列
%%%%%%%%hamming编码%%%%%
ConCode=encode (OrigiSeq,7,4,'linear',genmat);  %线性分组码编码后序列
%%%%%BPSK调制%%%%%%%%
BPSKCode =pskmod(ConCode,2);
%%%%%%%定义信噪比%%%%%%%%%%%%
EbN0 =-5:8;  %EbN0-dB
snr=10.^(EbN0./10);  %转化为功率信噪比
error = zeros(1,10);
           
%%%%%%%%%%%%%信噪比循环接收统计误码率%%%%%%%%%%%%
for k = 1:length(EbN0)
    for b=1:100;
    %%%%%%%%%%%%%%加性高斯白噪声信道%%%%%%%%%%%
    RecCode = awgn(BPSKCode,EbN0(k),'measured');
    %%%%%%%%%%%%%%BPSK解调%%%%%%%%%%%%%%%
    
    % BPSKdecode = BPSKDecode(RecCode, Length*7/4);   %BPSK解调
  
    BPSKdecode=pskdemod(RecCode,2);  %%%%%%%上面的式子可以直接用自带pskdemod函数来解调,而不用调用函数%%%%%%%%%
    
  %% 纠错部分 

你可能感兴趣的:((7,4)线性分组码matlab仿真(包含纠错部分代码))