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

📄 unitray2.m

📁 根据TD-SCDMA系统的特点
💻 M
字号:
close all
clear all
randn('state',sum(100*clock))
  
A=1;
ES=A*A;
Eb=ES;
minTestLength=100000;
maxTestlength=100000000;
index=1;


for EbN0=11:15
N0=10^(-EbN0/10);
noiseRoot=sqrt(N0/2);
errorCount=0;
testCount=0;

length=0;


while(1)
    
% Generate the Rayleigh fading channel 
h0=(randn(1)+j*randn(1))*sqrt(0.5);
n=0;
a=(randn(1)+j*randn(1))*noiseRoot;
% for nn=1:16
% n(nn)=(randn(1)+j*randn(1))*noiseRoot;
% end
% Soure matrix
 
 matrix=(1/sqrt(8))*[1 1;1 exp(i*2*pi/8);1 exp(i*4*pi/8);1 exp(i*6*pi/8);1 exp(i*8*pi/8);1 exp(i*10*pi/8);1 exp(i*12*pi/8);1 exp(i*14*pi/8)]; 
  
% Generate Unitray Matrix 
 
 S_matrix=diag(exp([i*pi*2/256 i*pi*2*5/256 i*pi*2*16/256 i*pi*2*36/256 i*pi*2*57/256 i*pi*2*105/256 i*pi*2*151/256 i*pi*2*253/256]));
 % 8 rows 1 columns 

 % Transmit source matrix
 
 src=randn(1,8)>0;
 dec=[128 64 32 16 8 4 2 1]*src';
 
 % Transmit matrix
 Tsrc_matrix=sqrt(8)*S_matrix.^dec*matrix;
 
 % Receive matrix
 
 Rece_matrix=ones(8,2);
 
 % for m= 1:2
    % for mm=1:8
 
 Rece_matrix=0.707*h0*Tsrc_matrix+a;
 %end
 %end

 
 % Decision
 
 for ii=0:255
   
     TR=trace( Rece_matrix'*(S_matrix.^ii*matrix)*(S_matrix.^ii*matrix)'*Rece_matrix);
    % max angle
        if TR>n
         n=TR;
         length=ii;
     end
 end
 
  dst=de2bi(length,8,'left-msb');
  error=xor(src,dst);
  errorCount=errorCount+sum(error);
        testCount=testCount+8;
        if(testCount<minTestLength)
            continue;
        end
        tempBER=errorCount/testCount;

         %test if the test length is large enough
        if(tempBER>0)
            thresholdTestLength=100/(tempBER);
        else
            thresholdTestLength=maxTestLength;
        end
        
        %Stop current EbN0 test when the test threshold is reached
        if(testCount>=thresholdTestLength)
            myTestLength(index)=testCount;
            Es=Eb/2;
            myEsN0(index)=10*log10(Es/N0)
            myEbN0(index)=EbN0
            myBER(index)=tempBER
            index=index+1;
            break;
        end
    end
end

%Draw curves for the results,Eb/N0
figure(1)
semilogy(myEbN0,myBER,'*-');
xlabel('Eb/N0 in dB');
ylabel('bit error rate');
grid 

%Draw curves for the results, Es/N0
% figure(2)
% semilogy(myEsN0,myBER,'+-');
% xlabel('Es/N0 in dB');
% ylabel('bit error rate');
% grid 

 
 
 
 
 
 
 

⌨️ 快捷键说明

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