• 大小: 1KB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2021-05-10
  • 语言: 其他
  • 标签: 汉明码  bpsk  

资源简介

利用汉明码对信号进行编译码然后经过bpsk调制解调,绘出信噪比与误码率关系曲线

资源截图

代码片段和文件信息

function   linear( )
clc;
clear;
prompt={‘码元数目为:‘‘每个码元内的载波数:‘‘每周期抽样点数:‘}; 
title=‘FIGHT‘;line=1;
def={‘400‘‘10‘‘40‘};
y=inputdlg(prompttitlelinedef);
x=str2num(y{1});
f=str2num(y{2});
mm=str2num(y{3});
m=randsrc(1x[01]);
k=1;
num=[];
b=1;
num2=[];
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%编码
c=[];
G=[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];
for i=0:x/4-1
      ui=[];
    for d=4*i+1:4*i+4      
        ui=[uim(d)];
    end
    v=[];
    v=ui*G;
    mod(v2);
    c=[cv];
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%调制解调
for ai=0:0.5:10
SNR=ai-3*log2(mm*f)+3;
snr=1/(10^(SNR/10));
noise=sqrt(snr/2)*(randn(1length(c)*mm*f));
t=0:mm*f-1;
tu11=[];
tu2=[];
for e=1:length(c)
    if c(e)>0
        tu=ones(1mm*f);
        w=sin(2*pi*t/mm);
    else tu=-ones(1mm*f);
        w=-sin(2*pi*t/mm);
    end
    tu11=[tu11tu];
    tu2=[tu2w];
end
tu1=(tu11+1)/2;
t=0:mm*f*length(c)-1;
carr=sin(2*pi*t/mm);
noise_signal=tu2+noise;
ss=carr.*noise_signal;
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
rf=[];
rr1=[];
for e=1:length(c)
    sh=sum(ss(mm*f*e-mm*f+1:mm*f*e))/mm*f;
    if sh>=0
        a=ones(1mm*f);
        rr=1;
    else a=-ones(1mm*f);
        rr=0;
    end
    rf=[rfrr];
     rr1=[rr1a];
end
m

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%译码
Gd=[0 0 0 0 0 0 0;0 0 0 1 0 1 1;0 0 1 0 1 0 1;0 0 1 1 1 1 0;0 1 0 0 1 1 0;0 1 0 1 1 0 1; 0 1 1 0 0 1 1;0 1 1 1 0 0 0;1 0 0 0 1 1 1;1 0 0 1 1 0 0;1 0 1 0 0 1 0;1 0 1 1 0 0 1;1 1 0 0 0 0 1;1 1 0 1 0 1 0;1 1 1 0 1 0 0;1 1 1 1 1 1 1]; 
Rl=[];
  for i=0:length(rf)/7-1 
      r=rf(7*i+1:7*i+7);
      rm=rf(7*i+1:7*i+4);
            for d=1:7
              if r~=Gd(d:);
              end
            end
          r1=r&[0 1 1 1 1 1 1];
          r2=r&[1 0 1 1 1 1 1];
          r3=r&[1 1 0 1 1 1 1];
          r4=r&[1 1 1 0 1 1 1];
          for d=1:7
              if r1==Gd(d:)
                  rm=r1(1:4);
              end
              if r2==Gd(d:)
                  rm=r2(1:4);
              end
              if r3==Gd(d:)
                  rm=r3(1:4);
              end
              if r4==Gd(d:)
                  rm=r4(1:4);
              end              
          end         
      
Rl=[Rlrm];
  end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%抽样比较  
n=0;
n2=0;
for i=1:length(Rl)
    if m(i)~=Rl(i)
       n=n+1;
    end
end
for i=1:length(rf)
    if c(i)~=rf(i)
        n2=n2+1;
    end
end
num2(b)=n2/length(rf);
b=b+1;

num(k)=n/length(Rl);
k=k+1;
end
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%画图
t=0:0.5:10;
figure(1);
semilogy(tnum‘r-o‘‘LineWidth‘1);
grid on;
hold on;
semilogy(tnum2‘-*‘‘linewidth‘1);
title(‘误码率曲线‘‘FontSize‘25‘Fontweight‘‘bold‘);
xlabel(‘SNR(dB)‘);
ylabel(‘误码率Pe‘);
legend(‘编译码的pe‘‘未编译码的pe‘);
hold off;

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     文件        2991  2010-06-11 14:12  hangmingma.m

评论

共有 条评论