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

📄 original(lzf).m

📁 mimo-mc-cdma系统上行链路中分别针对单用户和多用户的不同检测算法的比较
💻 M
字号:
clear all
Nc=64;                          % the total carriers
K=1;                            % the number of users 
M=4;                            % the number of transmit antennas
N=4;                            % the number of receive antennas 
G=16;                            % the processing gain
S=Nc/G;                         % the number of signals of each group
Tc=1/1.2288e6;                  % chip duration 
Ts=Tc;                          % symbol duration
circle_times=10000;
SNR_dB=0:4:28;
%KK=4:2:16;
SGMA=1;
e=zeros(1,21);
  
%SNR_dB=20;
%SNR=10^(SNR_dB/10);
%Pow=2*SGMA^2*SNR;
%for x=1:length(KK)
%    K=4+2*(x-1);
    
H=zeros(N,M,Nc,K);
for k=1:K
  for p=1:Nc
    for m=1:M
      for n=1:N
        H(n,m,p,k)=raylrnd(0.5)*exp(j*2*pi*rand);  
      end
    end
    %Gg(:,:,p,k)=pinv(H(:,:,p,k));
    %Gg(:,:,p,k)=inv(H(:,:,p,k)'*H(:,:,p,k)+eye(M))*H(:,:,p,k)';
  end
end

for x=1:length(SNR_dB)
  SNR(x)=10^(SNR_dB(x)/10);
  Pow(x)=2*SGMA^2*SNR(x)/M;
  
  for t=1:circle_times
    TransmitSignal=rand(M,S,K);
    TransmitSignal=(TransmitSignal>=0.5)-(TransmitSignal<0.5);

    % spreading
    SpreadCode=hadamard(G);
    TS=[];
    for k=1:K
      SD=[];
      for s=1:S
        TS=TransmitSignal(:,[s*ones(1,G)],:);
        for g=1:G
          SpreadData(:,g,k)=TS(:,g,k)*SpreadCode(k,g);
        end
        SD=[SD SpreadData(:,:,k)];
      end
      SP(:,:,k)=SD;
    end

  % multicarrier modulation
    for p=1:Nc
      for k=1:K
         TX(:,p,k)=H(:,:,p,k)*SP(:,p,k);
      end
    end
    TX=sqrt(Pow(x))*ifft(TX,[],2); 
    %TX=sqrt(Pow)*ifft(TX,[],2);

  % transmit
    AWGN=SGMA*randn(N,Nc);
    TX=sum(TX,3);
    for p=1:Nc
       RX(:,p)=TX(:,p)+AWGN(:,p);
    end

  % demodulation
    DM=fft(RX,[],2);

  % multiuser detection and V-blast detection
    for p=1:Nc
       g=mod(p,G);
       if (g==0)
         g=G;
       end
       Gg(:,:,p)=eye(N);
       for k=1:K
          Gg(:,:,p)=Gg(:,:,p)+Pow(x)*H(:,:,p,k)*H(:,:,p,k)';
          %Gg(:,:,p)=Gg(:,:,p)+Pow*H(:,:,p,k)*H(:,:,p,k)';
       end
       for k=1:K
          DecisionVector(:,p,k)=DM(:,p)*SpreadCode(k,g);
          %Output(:,p,k)=Gg(:,:,p,k)* DecisionVector(:,p,k);
          R(:,:,p,k)=Gg(:,:,p);
          Output(:,p,k)=H(:,:,p,k)'*inv(R(:,:,p,k))*DecisionVector(:,p,k);
          %Output(:,p,k)=(real(Output(:,p,k)>=0))-(real(Output(:,p,k)<0));
       end
    end

  % subcarrier combination
    C=[];
    FinalData=[];
    for s=1:S
       C(:,:,:)=Output(:,(s-1)*G+1:s*G,:);
       %for m=1:M
       %  for g=1:G
       %      for k=1:K
       %         E(m,g,k)=C(m,g,k)*abs(real(C(m,g,k)));
       %      end
       %   end
       %end
       FinalData(:,s,:)=sum(C,2);
    end
    FinalData=(FinalData>=0)-(FinalData<0);

  % compute the BER
    e(x)=e(x)+0.5*sum(sum(sum(abs(TransmitSignal-FinalData))));
  end
  per(x)=e(x)/(S*M*K*circle_times);
end
hold on
semilogy(SNR_dB,per(:),'x')
xlabel('Eb/No(dB)');
%semilogy(KK,per(:),'x')
%xlabel('K');
ylabel('BER');
  

⌨️ 快捷键说明

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