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解调
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解调