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

📄 u.m

📁 Bit error probability curve for BPSK with channal for wimax
💻 M
字号:
clc;
clear all; 
noofpts=512;  
noofcp =64;  
noofdata=8; 
noofnoise=1;
nooftaps=22;  
noofframes=500;
                                      %%%%%%%%%%%%%%%%%%%%%%%%%%   preamble generation
prb(1,:)=[0 0 0 0 0 0 0 1 1 1 1 0 0 1 0 1 0 0 1 0 1 1 0 0 1 0 0 1 1 0 1 1 0 0 1 1 1 1 1 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 0 0 0 1 0 0 0 1 0 0 1 0 0 1 1 1 0 1 1 1 0 0 1 0 0 0 1 0 1 0 0 1 0 0 1 1 1 1 0 1 0 0 1 0 0 0 1 0 1 1 0 1 0 0 1 1 0 1 0 1 0 0 1 0 1 0 0 0 1 0 0 0 0 1 1 1 1 1 0]; 
prb(2,:)=[1 1 0 1 1 0 0 0 1 1 0 0 0 0 1 1 0 0 0 0 1 1 0 1 1 0 1 0 0 1 0 1 1 0 0 0 1 0 1 1 0 1 0 1 1 1 1 0 1 1 0 1 0 1 1 1 0 0 0 1 0 0 0 0 0 1 0 1 0 1 1 0 1 1 0 0 0 1 0 1 1 1 0 1 0 1 1 1 1 0 0 1 0 0 0 0 0 0 1 1 0 0 1 0 1 0 1 1 1 0 0 0 0 0 0 0 1 1 1 0 0 0 0 0 0 1 0 1 0 1 0 1 0 0 1 0 0 0 1 0 1 1 0 0];
lenprb=length(prb(1,:));
 for i=1:2                               %segment number
     for j=1:lenprb     
         pos(j,i)=i+3*(j-1);             %freq position
     end
 end
 bpskdata=sign(prb(1,:)-0.5) ;
 prefixdata=zeros(1,pos(lenprb));
 postdata=zeros(1,pos(lenprb));
 postdata(pos(:,1))=bpskdata ;
 postdata(length(postdata)/2+1)=0 ;
 prezero=zeros(1,42);
 postzero=zeros(1,41);
 before=[prezero postdata postzero]; 
 preambledata=[before(257:512) before(1:256)];
 preifft=ifft(preambledata,noofpts);
 cppreamble=[preifft(noofpts-noofcp+1:noofpts) preifft].';
 preampwr=sum(abs(cppreamble).^2)/(noofcp+noofpts);
 %datprezero=zeros(1,46);
 % data=complex(randsrc(noofdata,420),randsrc(noofdata,420));
 %title('Program Running')
 data=randsrc(noofdata,noofpts);
 noofdatas=noofdata*noofpts;
 data1=reshape(data',noofdatas,1);
 data3=reshape(data',noofdatas,1);
 for i=1:noofpts*noofdata
        if (real (data1(i))>=0)
               data1(i)=1;
     elseif(real(data1(i))<0);
         data1(i)=0;
              end
 end
 for i=1:noofdata
     dataifft=ifft(data(i,:),noofpts);
     pdata(i,:)=[dataifft(noofpts-noofcp+1:noofpts) dataifft];
 end
 cpdata=pdata.';
 [datarow datacol]=size(cpdata);
 temp=pdata.*conj(pdata);
 datapwr=sum(sum(temp))/(datarow*datacol);
 s=sqrt(8*datapwr)*cppreamble/sqrt(preampwr);
 spwr=sum(abs(s).^2)/(noofcp+noofpts);
 fmeframe=[s cpdata];
 fremefremae=reshape(fmeframe,(noofpts+noofcp)*(datacol+1),1);
 normtap=[0.4368 0.3469 0 0 0.1381 0 0 0.0692 0 0 0 0 0 0.0072 0 0 0 0 0 0 0 0.0017]
for snrr=1:36
 snrr;
 count(snrr)=0;
 noofruns=10;
    for r=1:noofruns
          for i=1:nooftaps
              ch(i)=sqrt(normtap(i))*0.707*complex(randn(1,1),randn(1,1));
          end
     hfft=conj(fft(ch,noofpts));
     magsqr=abs(hfft).^2;
     scalftr=hfft./magsqr;
     convolution1=conv(ch,fremefremae);
     [M N]=size(convolution1);               %%%%%%%%%%% 0r size(convolution2)
     convpwr1=sum(abs(convolution1).^2)/(M*N);
     noise_pow=convpwr1*10^(-snrr/10); 
     noise=sqrt(noise_pow)*0.707*complex(randn(M,1),randn(M,1)); 
     noisepwr=sum(abs(noise).^2)/M;
     withnoise=noise+convolution1; 
     wthnsepwr=sum(abs(withnoise).^2)/M;
     withnoise1=withnoise(577:end);
             for i=1:noofdata
               rmcpcl=withnoise1(i*(noofcp+noofpts)-noofpts+1:i*(noofcp+noofpts));
               rmcpclmat(:,i)=rmcpcl;
             end
     invfft=fft(rmcpclmat,noofpts);
             for i=1:noofdata
                 scaledfft(:,i)=invfft(:,i).*(scalftr.');
             end 
      data2=reshape(scaledfft,noofdatas,1);     
            for i=1:noofpts*noofdata
                    if (real(data2(i))>=0)
                        data2(i)=1;
                    else(real(data2(i))<0)
                        data2(i)=0;
                    end  
            end     
     error=data1-data2;
            for i=1:noofdatas
                if error(i)==0
                   count(snrr)=count(snrr);
                else 
                   count(snrr)=count(snrr)+1;
                end
            end
      snrratio=convpwr1/noisepwr
     snrr;
      end
 result(snrr)=count(snrr)/(noofdatas*noofruns);
end
snrr=[1:36];
semilogy(snrr,result,'bs-','LineWidth',2);
axis([0 40 10^-5 1])
xlabel('SNR, dB')
ylabel('Bit Error Rate')
title('Bit error probability curve for BPSK with channal for wimax')

⌨️ 快捷键说明

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