⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ee359.m

📁 本程序利用改进的CHOW算法
💻 M
字号:
%This Matlab Script helps to determine how multipath delay spread
%affects the irreducible error floor (infinite SNR). It uses
%mex files for the modulator, demodulator, channel simulator, 
%and convolutional coder.
% written by Joe Williams - Stanford Univeristy EE Dept.

num_of_iterations=1; %number of times to calc BER at each time
BER=0;
baud_rate=20000000; %20Msymbols/sec
conv=1; %use convolutional coder if 1
%SNR=30; %currently infinite
g=[1 0 1;1 1 1;1 1 1;1 1 1]; %generating polynomial for convolutinal coder
in=zeros(1,10000);

%channel=0;%no ISI
channel=1;%two-ray model
%channel=2;%three-ray model

%tag=0;%FSK
%tag=1;%BPSK
%tag=2;%QPSK
tag=3;%16PSK
%tag=4;%16QAM %no impl.
%tag=5;%DPSK  %not impl.

for k=1:60
  multipath=(k-1)*20+1; %for 2 ray channel model
  %multipath=(k-1)*40+1; %for 3 ray channel model
  num_errors=0; %reset error counter
  
  for i=1:num_of_iterations %for each iteration
    in=round(rand(1,10000)); %generate a random binary data sequence
    in_comp=in; %preserve a copy to compare at end
    if conv==1 %if coding
      in2=encode_blockmex(g,in); %mex file for conv. encode
    else
      in2=in; %dont code
    end;
    
    for l=1:length(in2) %simple fix if coder outputs a non-binary digit
      if in2(l)>1 in2(l)=1;
      elseif in2(l)<0 in2(l)=0;
      end
    end

    %convert data into approp. message and set tag for demod
    %ex. if using QPSK {0 0 0 1 1 0 1 1} becomes {0 1 2 3}
    
    if tag==0
      outtag=1;
    elseif tag==1
      outtag=2;
    elseif tag==2
      in=binvec2quadvec(in);
      outtag=3;
    elseif tag==3
      in=binvec216vec(in2);
      outtag=4;
    elseif tag==4
      in=binvec216vec(in);
      outtag=5;
    elseif tag==5
      outtag=6;
    end;
  
    in=gray_encode(in);
    mod=modulatormex(in,baud_rate,tag); %digitally modulate the input 
    mod=channel_simulatormex(mod,channel,multipath); %simulate a channel
    %mod=awgn(mod,SNR); %add noise to mod waveform
    [out,eie0,eie1]=demodulatormex(mod,baud_rate,length(in),outtag); %demodulate waveform
    out=gray_decode(out);
    
    %convert message back into binary data stream
    if tag==2
      out=quadvec2binvec(out);
    elseif tag==3 | tag==4
      out=sixteenvec2binvec(out);
    end;
  
    if conv==1
      out2=hard_decodemex2(g,out);
    else
      out2=out;
    end;
  
    %dtermine the number of errors
    for j=1:length(in_comp)
      if out2(j)~=in_comp(j)
        num_errors=num_errors+1;
      end;
    end;
  
  end;
  BER(k,1)=num_errors;
  k %display progress
  BER
end;

samplesperbit=900000000*20/baud_rate;%samplesperibt = carrier freq * samples/period / baudrate;

%compute normalized delay spread
for k=1:60
   x(k)=(k-1)*20/samplesperbit;  %for 2rays
   %x(k)=(k-1)*40/samplesperbit; %for 3rays
end;

%plot the resulting "irreducible" error floor
plot(x,BER/(num_of_iterations*length(in_comp)))
xlabel('Normalized Delay Spread');
ylabel('Average Irreducible BER');
%plot the scatter
%plot(eie0,eie1,'.');

⌨️ 快捷键说明

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