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

📄 softjudge.m

📁 根据TD-SCDMA系统的特点
💻 M
字号:
clear all ;
close all;

randn('state',sum(100*clock)); %reset the randn generator

 minTestLength=1000; % test length should at least reach this number
 maxTestLength=100000; %test stops at this number 
% unitray matrix
matrix0=ones(6,1);
smatrix=diag(exp([i*2*pi/64 i*2*pi*18/64 i*2*pi*23/64 i*2*pi*39/64 i*2*pi*46/64 i*2*pi*57/64]));
Es=1;
Eb=Es;
index=1;

% leg=3;
% codegenerate=[4 3 7];
% trellis=poly2trellis(leg,codegenerate);
% tblen=2;

index=1;
% for 
EbN0=1
N0=10^(-EbN0/10)
noiseRoot0=sqrt(N0/2);
errorCount=0;
testCount=0;
% channeland noise




 while(1)
 h0=(randn(1)+j*randn(1))*sqrt(0.5);    
noise=(randn(6,30)+j*randn(6,30))*noiseRoot0;
source11=randint(1,60);


% Go = [11 0 13; 0 11 15];                         % Generator of outer encoder
Go = [4 3 7];
BGo = [11; 11];                                  % Generator of outer encoder
% Ko = [4 4] ;                                     % Restrain length of outer encoder    
Ko = [3] ;                                     % Restrain length of outer encoder    
mo = 3 ;
% to = poly2trellis(Ko, Go, BGo) ;
to = poly2trellis(Ko, Go) ;
source = convenc(source11, to);
% source=convenc(source11,trellis);% length=120

% source 
changesource=reshape(source,6,30);

dsource=zeros(6,30); % after decesion sign matrix

% spreadcode1=zeros(1,44);% spread array 

unitraymatrix=zeros(6,30);  % unitray modulate matrix

rmatrix=zeros(1,30);   % receive matrix

rsource=zeros(1,180);  % after despread  sign

index1=1;
for ii=1:30  % construct unitrary matrix
number(index1)=[32 16 8 4 2 1]*changesource(:,ii);
index1=index1+1;
end

for iii=1:30 % construct matrix
smatrix1=smatrix^number(iii)*matrix0;
unitraymatrix(:,iii)=unitraymatrix(:,iii)+smatrix1;
end

% spreadcode1=[reshape(unitraymatrix,1,42) zeros(1,2)];% symbols frame 
 % s1=[reshape(unitraymatrix,1,120)];
% t1=(randn(1,44))+j*(randn(1,44));
% source1 =spreadcode1*WQ(1);
% x1 = ovsf(1)' * source1;                 % spreading
% s1 = x1.*(scramble'*ones(1,44));               

% t2=(randn(1,44))+j*(randn(1,44));
% source2 = t2*WQ(2);
% x2 = ovsf(2)' * source2;                 % spreading
% s2 = x2.*(scramble'*ones(1,44));        


 
s1 =h0*unitraymatrix+noise;
% s=s1+s2;

% y1 = reshape(s,1,44*16) ;
%y = y + 1/sqrt(2)*( randn(size(y)) + j*randn(size(y)))*5;
% r = reshape(y1,16,44);

% y2 = reshape(s,1,44*16) ;
% y = y + 1/sqrt(2)*( randn(size(y)) + j*randn(size(y)))*5;
% r2 = reshape(y2,16,44);

% z1 = ones(44, 1)*scramble.*(ones(44, 1)*ovsf(1))*r;
% rs1 = reshape(diag(z1)/16,1,44)./WQ(1);

%z11 = ones(44, 1)*scramble.*(ones(44, 1)*ovsf(1))*r2;
% rs11 = reshape(diag(z1)/16,1,44)./WQ(1);


 % z2 = ones(44, 1)*scramble.*(ones(44, 1)*ovsf(2))*r;
 % rs2 = reshape(diag(z2)/16,1,44)./WQ(2);
 
 % for mmm=1:42
   %   rematrix(mmm)=rs1(mmm);
   % end
 
dmatrix=s1;

for nn=1:30
    n=0;
    second=0;
    length=0;
    length2=0;
    diff=0;
    for nnn=0:63
     TR=real(trace( dmatrix(:,nn)'*(smatrix^nnn*matrix0)*(smatrix^nnn*matrix0)'*dmatrix(:,nn)));
    % max angle
        if TR>n
           second=n;
           length2=length;
            n=TR;
            length=nnn;
        
    elseif TR>second
        second=TR;
        length2=nnn;
            
     end
 end
 diff=n-second;
 dst=2*de2bi(length,6,'left-msb')-1;
 dst2=2*de2bi(length2,6,'left-msb')-1;
 rrrr=zeros(1,6);
 for kk=1:6
     if dst(kk)==dst2(kk)
         rrrr(kk)=dst(kk)*n;
     else
         rrrr(kk)=dst(kk)*diff;
     end
 end
 dsource(:,nn)=dsource(:,nn)+rrrr';
end
rsource=reshape(dsource,1,180);%>0;
% code=zeros(1,180);
% for kkkk=1:180
%    code(kkkk)=rsource(kkkk);
% end
lle = zeros(size(rsource));
[rsource1  lle] = sovaO(rsource, zeros(size(rsource)), 30);        % outer sova decoder
lle
%rsource1=vitdec(code,trellis,tblen,'trunc','hard');

err=xor(rsource1,source11);
        errorCount=errorCount+sum(err);
        testCount=testCount+60;
         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 + -