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

📄 twoto22.m

📁 ldpc在系统矩阵twoto下的系统仿真
💻 M
📖 第 1 页 / 共 2 页
字号:
path22_5=[zeros(1,7) path22_5 zeros(1,3)];
path22_6=[zeros(1,10) path22_6];
RxSignal31=path22_1+path22_2+path22_3+path22_4+path22_5+path22_6;
RxSignal31=RxSignal31(1:FrameGuard*Numsymb);

%1st transmitter to 2st receiver H12*BaseSignal2
path12_1=ones(FrameGuard,1)*fade(1,[1+2000:Numsymb+2000]).*BaseSignal2;
path12_2=ones(FrameGuard,1)*fade(2,[1+2000:Numsymb+2000]).*BaseSignal2;
path12_3=ones(FrameGuard,1)*fade(3,[1+2000:Numsymb+2000]).*BaseSignal2;
path12_4=ones(FrameGuard,1)*fade(4,[1+2000:Numsymb+2000]).*BaseSignal2;
path12_5=ones(FrameGuard,1)*fade(5,[1+2000:Numsymb+2000]).*BaseSignal2;
path12_6=ones(FrameGuard,1)*fade(6,[1+2000:Numsymb+2000]).*BaseSignal2;
path12_1=reshape(path12_1,1,size(path12_1,1)*size(path12_1,2));
path12_2=reshape(path12_2,1,size(path12_2,1)*size(path12_2,2));
path12_3=reshape(path12_3,1,size(path12_3,1)*size(path12_3,2));
path12_4=reshape(path12_4,1,size(path12_4,1)*size(path12_4,2));
path12_5=reshape(path12_5,1,size(path12_5,1)*size(path12_5,2));
path12_6=reshape(path12_6,1,size(path12_6,1)*size(path12_6,2));
path12_1=[path12_1 zeros(1,10)];    % the largest delay is 10 sample                                                                                                                          
path12_2=[zeros(1,1) path12_2 zeros(1,9)];
path12_3=[zeros(1,3) path12_3 zeros(1,7)];
path12_4=[zeros(1,4) path12_4 zeros(1,6)];
path12_5=[zeros(1,7) path12_5 zeros(1,3)];
path12_6=[zeros(1,10) path12_6];
RxSignal21=path12_1+path12_2+path12_3+path12_4+path12_5+path12_6;
RxSignal21=RxSignal21(1:FrameGuard*Numsymb);

%2st transmitter to 2st receiver H22*BaseSignal3
path22_1=ones(FrameGuard,1)*fade(1,[1+3000:Numsymb+3000]).*BaseSignal3;
path22_2=ones(FrameGuard,1)*fade(2,[1+3000:Numsymb+3000]).*BaseSignal3;
path22_3=ones(FrameGuard,1)*fade(3,[1+3000:Numsymb+3000]).*BaseSignal3;
path22_4=ones(FrameGuard,1)*fade(4,[1+3000:Numsymb+3000]).*BaseSignal3;
path22_5=ones(FrameGuard,1)*fade(5,[1+3000:Numsymb+3000]).*BaseSignal3;
path22_6=ones(FrameGuard,1)*fade(6,[1+3000:Numsymb+3000]).*BaseSignal3;
path22_1=reshape(path22_1,1,size(path22_1,1)*size(path22_1,2));
path22_2=reshape(path22_2,1,size(path22_2,1)*size(path22_2,2));
path22_3=reshape(path22_3,1,size(path22_3,1)*size(path22_3,2));
path22_4=reshape(path22_4,1,size(path22_4,1)*size(path22_4,2));
path22_5=reshape(path22_5,1,size(path22_5,1)*size(path22_5,2));
path22_6=reshape(path22_6,1,size(path22_6,1)*size(path22_6,2));
path22_1=[path22_1 zeros(1,10)];    % the largest delay is 10 sample                                                                                                                          
path22_2=[zeros(1,1) path22_2 zeros(1,9)];
path22_3=[zeros(1,3) path22_3 zeros(1,7)];
path22_4=[zeros(1,4) path22_4 zeros(1,6)];
path22_5=[zeros(1,7) path22_5 zeros(1,3)];
path22_6=[zeros(1,10) path22_6];
RxSignal30=path22_1+path22_2+path22_3+path22_4+path22_5+path22_6;
RxSignal30=RxSignal30(1:FrameGuard*Numsymb);

% ==============================
% the ideal channel response
% ==============================
H11_real=zeros(NumCarr,Numsymb);      % the real channel impulse response
for k=1:NumCarr
    H11_real(k,:)=H11_real(k,:)+fade(1,[1:Numsymb])*exp(-j*2*pi*(k-1)*0/NumCarr)+fade(2,[1:Numsymb])*exp(-j*2*pi*(k-1)*1/NumCarr)+...
                            fade(3,[1:Numsymb])*exp(-j*2*pi*(k-1)*3/NumCarr)+fade(4,[1:Numsymb])*exp(-j*2*pi*(k-1)*4/NumCarr)+...
                            fade(5,[1:Numsymb])*exp(-j*2*pi*(k-1)*7/NumCarr)+fade(6,[1:Numsymb])*exp(-j*2*pi*(k-1)*10/NumCarr);
end
H11_re= H11_real([29:229],:);

H21_real=zeros(NumCarr,Numsymb);      % the real channel impulse response
for k=1:NumCarr
    H21_real(k,:)=H21_real(k,:)+fade(1,[1+1000:Numsymb+1000])*exp(-j*2*pi*(k-1)*0/NumCarr)+fade(2,[1+1000:Numsymb+1000])*exp(-j*2*pi*(k-1)*1/NumCarr)+...
                            fade(3,[1+1000:Numsymb+1000])*exp(-j*2*pi*(k-1)*3/NumCarr)+fade(4,[1+1000:Numsymb+1000])*exp(-j*2*pi*(k-1)*4/NumCarr)+...
                            fade(5,[1+1000:Numsymb+1000])*exp(-j*2*pi*(k-1)*7/NumCarr)+fade(6,[1+1000:Numsymb+1000])*exp(-j*2*pi*(k-1)*10/NumCarr);
end
H21_re= H21_real([29:229],:);

H12_real=zeros(NumCarr,Numsymb);      % the real channel impulse response
for k=1:NumCarr
    H12_real(k,:)=H12_real(k,:)+fade(1,[1+2000:Numsymb+2000])*exp(-j*2*pi*(k-1)*0/NumCarr)+fade(2,[1+2000:Numsymb+2000])*exp(-j*2*pi*(k-1)*1/NumCarr)+...
                            fade(3,[1+2000:Numsymb+2000])*exp(-j*2*pi*(k-1)*3/NumCarr)+fade(4,[1+2000:Numsymb+2000])*exp(-j*2*pi*(k-1)*4/NumCarr)+...
                            fade(5,[1+2000:Numsymb+2000])*exp(-j*2*pi*(k-1)*7/NumCarr)+fade(6,[1+2000:Numsymb+2000])*exp(-j*2*pi*(k-1)*10/NumCarr);
end
H12_re= H12_real([29:229],:);

H22_real=zeros(NumCarr,Numsymb);      % the real channel impulse response
for k=1:NumCarr
    H22_real(k,:)=H22_real(k,:)+fade(1,[1+3000:Numsymb+3000])*exp(-j*2*pi*(k-1)*0/NumCarr)+fade(2,[1+3000:Numsymb+3000])*exp(-j*2*pi*(k-1)*1/NumCarr)+...
                            fade(3,[1+3000:Numsymb+3000])*exp(-j*2*pi*(k-1)*3/NumCarr)+fade(4,[1+3000:Numsymb+3000])*exp(-j*2*pi*(k-1)*4/NumCarr)+...
                            fade(5,[1+3000:Numsymb+3000])*exp(-j*2*pi*(k-1)*7/NumCarr)+fade(6,[1+3000:Numsymb+3000])*exp(-j*2*pi*(k-1)*10/NumCarr);
end
H22_re= H22_real([29:229],:);

    a0_re=abs(H11_re);
    a1_re=abs(H21_re);
    a2_re=abs(H12_re);
    a3_re=abs(H22_re);
    A_re=a0_re.^2+a1_re.^2+a2_re.^2+a3_re.^2-1;
    B_re=zeros(NumCarr,Numsymb);
    B_re([29:229],:)=A_re;
    C_re=B_re(Data_Pattern);

Lc=Lcp/2;
    
    RxSigna00=RxSignal00;
    RxSigna11=RxSignal11;
    RxSigna01=RxSignal01;
    RxSigna10=RxSignal10;
    RxSigna20=RxSignal20;
    RxSigna31=RxSignal31;
    RxSigna21=RxSignal21;
    RxSigna30=RxSignal30;
    
    % Strip off the guard interval
  symb00= reshape(RxSigna00,NumCarr+Lc,Numsymb);
  symb00= symb00(Lc+1:NumCarr+Lc,:); 
  symb11= reshape(RxSigna11,NumCarr+Lc,Numsymb);
  symb11= symb11(Lc+1:NumCarr+Lc,:); 
  symb01= reshape(RxSigna01,NumCarr+Lc,Numsymb);
  symb01= symb01(Lc+1:NumCarr+Lc,:); 
  symb10= reshape(RxSigna10,NumCarr+Lc,Numsymb);
  symb10= symb10(Lc+1:NumCarr+Lc,:); 
  symb20= reshape(RxSigna20,NumCarr+Lc,Numsymb);
  symb20= symb20(Lc+1:NumCarr+Lc,:); 
  symb31= reshape(RxSigna31,NumCarr+Lc,Numsymb);
  symb31= symb31(Lc+1:NumCarr+Lc,:); 
  symb21= reshape(RxSigna21,NumCarr+Lc,Numsymb);
  symb21= symb21(Lc+1:NumCarr+Lc,:); 
  symb30= reshape(RxSigna30,NumCarr+Lc,Numsymb);
  symb30= symb30(Lc+1:NumCarr+Lc,:); 
     
R00=fft(symb00);
R11=fft(symb11);
R01=fft(symb01);
R10=fft(symb10);
R20=fft(symb20);
R31=fft(symb31);
R21=fft(symb21);
R30=fft(symb30);

R0=R00+R11;
R1=R01+R10;
R2=R20+R31;
R3=R21+R30;

R0=awgn(R0,10^(SNR/10),'measured',1234,'linear');
R1=awgn(R1,10^(SNR/10),'measured',1234,'linear');
R2=awgn(R2,10^(SNR/10),'measured',1234,'linear');
R3=awgn(R3,10^(SNR/10),'measured',1234,'linear');

    %提取导频数据
	Rec_Pilot11=R0(Pilot1_Pattern);
    Rec_Pilot21=R0(Pilot2_Pattern);
    Rec_Pilot12=R2(Pilot1_Pattern);
    Rec_Pilot22=R2(Pilot2_Pattern);
   %估计导频处的信道频域响应
	H11_Pilot=Rec_Pilot11./Data0(Pilot1_Pattern);
    H21_Pilot=Rec_Pilot21./Data1(Pilot2_Pattern);
    H12_Pilot=Rec_Pilot12./Data0(Pilot1_Pattern);
    H22_Pilot=Rec_Pilot22./Data1(Pilot2_Pattern);
    
    H11_Pilot=reshape(H11_Pilot,Pilot1_number,Numsymb);
    H21_Pilot=reshape(H21_Pilot,Pilot2_number,Numsymb);
    H12_Pilot=reshape(H12_Pilot,Pilot1_number,Numsymb);
    H22_Pilot=reshape(H22_Pilot,Pilot2_number,Numsymb);
    
% ===========================================
% ls estimation
% ===========================================
%Pilot1=[37:8:221]-28;     % pilot interval=24
%Pilot2=[40:8:224]-28;

%    XI=1:201;
%    H11= INTERP1(Pilot1,H11_Pilot,XI,'linear','extrap');
%    H21= INTERP1(Pilot2,H21_Pilot,XI,'linear','extrap');
%    H12= INTERP1(Pilot1,H12_Pilot,XI,'linear','extrap');
%    H22= INTERP1(Pilot2,H22_Pilot,XI,'linear','extrap');
    
% ===========================================
% LMMSE estimation
% ===========================================
% L1=10;
% for m=1:NumCarr
%    for n=1:NumCarr
%        if m==n
%            Rhh(m,n)=1;
%        else
%           Rhh(m,n)=(1-exp(-j*2*pi*(m-n)*L1/NumCarr))/(j*2*pi*(m-n)*L1/NumCarr);
%       end
%   end
% end
%    M=[29:229];
%    N1=[37:8:221];
%    R1_h_hls=Rhh(M,N1);
%    R1_hls_hls=Rhh(N1,N1)+1/10^(SNR/10)*eye(length(N1));
%    RR1=R1_h_hls*inv(R1_hls_hls);
        
%    N2=[40:8:224];
%    R2_h_hls=Rhh(M,N2);
%    R2_hls_hls=Rhh(N2,N2)+1/10^(SNR/10)*eye(length(N2));
%    RR2=R2_h_hls*inv(R2_hls_hls);
    
 %  H11=RR1*H11_Pilot; 
 %   H21=RR2*H21_Pilot; 
 %   H12=RR1*H12_Pilot;
 %   H22=RR2*H22_Pilot;
    
% ===========================================
% ML esitmation 
% ===========================================
 F=dftmtx(NumCarr);
 L=11;
 Fh1=F([37:8:221],[1:L]);
 Fh2=F([40:8:224],[1:L]);
 Fu=F([29:229],[1:L]);
 H11=Fu*inv(Fh1'*Fh1)*Fh1'*H11_Pilot;
 H21=Fu*inv(Fh2'*Fh2)*Fh2'*H21_Pilot;
 H12=Fu*inv(Fh1'*Fh1)*Fh1'*H12_Pilot;
 H22=Fu*inv(Fh2'*Fh2)*Fh2'*H22_Pilot;
 
    a0=abs(H11);
    a1=abs(H21);
    a2=abs(H12);
    a3=abs(H22);
    A=a0.^2+a1.^2+a2.^2+a3.^2-1;
    B=zeros(NumCarr,Numsymb);
    B([29:229],:)=A;
    C=B(Data_Pattern);
    
%combinea s0,s1
Rx0=R0([29:229],:);
Rx1=R1([29:229],:);
Rx2=R2([29:229],:);
Rx3=R3([29:229],:);
s0=conj(H11).*Rx0+H21.*conj(Rx1)+conj(H12).*Rx2+H22.*conj(Rx3);
s1=conj(H21).*Rx0-H11.*conj(Rx1)+conj(H22).*Rx2-H12.*conj(Rx3);

s0=s0;
s1=s1;

%combinea s0,s1 using ideal channel estimation
s0_idea=conj(H11_re).*Rx0+H21_re.*conj(Rx1)+conj(H12_re).*Rx2+H22_re.*conj(Rx3);
s1_idea=conj(H21_re).*Rx0-H11_re.*conj(Rx1)+conj(H22_re).*Rx2-H12_re.*conj(Rx3);

s0_idea=s0_idea;
s1_idea=s1_idea;

%ml estimation demodulated
Rxx0=zeros(NumCarr,Numsymb);
Rxx1=zeros(NumCarr,Numsymb);     
    
Rxx0([29:229],:)=s0;
Rxx1([29:229],:)=s1;

% extract data
DemSignal0=Rxx0(Data_Pattern);
DemSignal1=Rxx1(Data_Pattern);



%ideal estimation demodulated
Rxx0_idea=zeros(NumCarr,Numsymb);
Rxx1_idea=zeros(NumCarr,Numsymb);     
    
Rxx0_idea([29:229],:)=s0_idea;
Rxx1_idea([29:229],:)=s1_idea;

% extract data
DemSignal0_idea=Rxx0_idea(Data_Pattern);
DemSignal1_idea=Rxx1_idea(Data_Pattern);

Dem1=DemSignal0_idea;
Dem2=DemSignal1_idea;



⌨️ 快捷键说明

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