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

📄 pilot_insert.m

📁 程序里面包含各部分算法仿真 可供参考和使用
💻 M
字号:
function [pilot_added ,known_pilot] = pilot_insert(st_coded,N_pilot_sym_ts,N_data_sym_ts,N_ts,Pos_pilot_sym,...
    Pos_data_sym,Idx_pilot,PilotValue,N_subc,Idx_used,N_Tx_ant,L_delay,MIMO_CE_Method ,SwitchOrthogonalPilot);

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% 在数据OFDM符号中加间隔的导频,并在数据符号帧之间插入导频OFDM符号
% 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

% 加导频OFDM符号,共加入 N_pilot_sym_ts*N_ts*N_Tx_ant 个,用于信道估计. 导频OFDM符号是伪随机序列
PN_seq = mseq( 12 , [2 4 7 10] , [1 1 1 1 0 0 0 0 0 0 0 0], N_pilot_sym_ts*N_ts*N_Tx_ant);

% BPSK调制导频符号
PN_seq = 2*PN_seq' - 1; 
tmp = PN_seq(1:length(Idx_used) , :);

%  插入的导频值

 PN_seq1 = mseq( 12 , [2 4 7 10] , [1 1 0 1 0 0 0 1 0 1 0 0], 1);
PN_seq2 = mseq( 12 , [1 3 5] , [0 0 0 1 0 1 0 0 0 1 0 0], 1);
PN_seq3 = mseq( 12 , [3 5 10] , [0 0 1 1 0 1 1 0 0 1 1 0], 1);
PN_seq4 = mseq( 12 , [6 8 9] , [ 1 0 1 0 1 0 0 1 1 1 0 1], 1);
% For Orthogonal Design Pilot . 
tmp = 2*PN_seq1(1:length(Idx_used))' - 1; 
% For Non-Orthogonal Design Pilot . 
tmp1 = tmp;
tmp2 = tmp*exp(j*pi/2);
tmp3 = tmp*exp(j*pi);
tmp4 = tmp*exp(j*3*pi/2);


% 为返回变量预先定义存储空间
pilot_added = zeros(N_subc,N_ts*(N_pilot_sym_ts + N_data_sym_ts), N_Tx_ant);
known_pilot = zeros(N_subc,N_ts*N_pilot_sym_ts,N_Tx_ant);
% 中间变量
pilot_ofdm_sym = zeros(N_subc,N_pilot_sym_ts);
N_used = length(Idx_used);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for ant = 1:N_Tx_ant
    % 加数据OFDM符号中的间隔导频,用于同步
    st_coded(Idx_pilot,:,ant) = repmat(PilotValue,1,size(st_coded,2));
    
    % 每个时隙加入的导频OFDM符号N_pilot_sym_ts个,放在位置Pos_pilot_sym上
    % 如果是单天线,则接收机分别估计出导频位置的频域信道响应,然后进行时域插值
    % 如果是多天线,则不同发送天线的导频不同,接收机分别估计导频位置的频域信道响应,然后进行时域插值
    
    for ts = 1:N_ts
        pilot_ofdm_sym = zeros(N_used,N_pilot_sym_ts);
        % 此处加入不同的插导频的方法
        
        if (N_Tx_ant~= 1) & (MIMO_CE_Method == 1)
            % 得到当前时隙的导频符号,注意:导频OFDM符号和数据OFDM符号的功率相同,都需要进行发送天线归一化! 
            %pilot_ofdm_sym(Idx_used,:) = PN_seq( 1:length(Idx_used) ,(ant + ts - 2)*N_pilot_sym_ts + 1: ...
            %    (ant + ts - 2)*N_pilot_sym_ts + N_pilot_sym_ts ) / sqrt(N_Tx_ant) ;
            
            % 为简化接收机复杂度,假设不同时隙,不同导频位置的PN序列相同
            pilot_ofdm_sym(Idx_used,:) = repmat( PN_seq( 1:length(Idx_used) ,ant) / sqrt(N_Tx_ant) , 1 ,N_pilot_sym_ts);
            
        elseif (N_Tx_ant~= 1) & (MIMO_CE_Method == 2)
            % 使用不同发送天线正交的训练序列
            % Imad Barhumi提出的训练序列,满足相位旋转正交特性
            pilot_ofdm_sym(Idx_used,:) = repmat(exp(-j*2*pi*ant*L_delay.*[0:N_used-1]'/N_used),1,N_pilot_sym_ts) / sqrt(N_Tx_ant) ;
            
        elseif (N_Tx_ant~= 1) & (MIMO_CE_Method == 3)
            % 使用不同发送天线正交的训练序列,加权信道估计改进
            pilot_ofdm_sym(Idx_used,:) = repmat(exp(-j*2*pi*ant*L_delay.*[0:N_used-1]'/N_used),1,N_pilot_sym_ts) / sqrt(N_Tx_ant);
            
        elseif (N_Tx_ant~= 1) & (MIMO_CE_Method == 4)
            % 使用不同发送天线正交的训练序列,Robust信道估计改进
            pilot_ofdm_sym(Idx_used,:) = repmat(exp(-j*2*pi*ant*L_delay.*[0:N_used-1]'/N_used),1,N_pilot_sym_ts) / sqrt(N_Tx_ant);
            
        elseif (N_Tx_ant~= 1) & (MIMO_CE_Method == 5)
            % 不同的发送天线使用不同的子载波间隔传导频
            tmp = PN_seq( 1:length(Idx_used)/N_Tx_ant ,(ant + ts - 2)*N_pilot_sym_ts + 1: ...
                (ant + ts - 2)*N_pilot_sym_ts + N_pilot_sym_ts );
            Idx_ant = Idx_used(ant:N_Tx_ant:length(Idx_used));
            pilot_ofdm_sym(Idx_ant,:) = tmp / sqrt(N_Tx_ant);
            
            
        elseif (N_Tx_ant~= 1) & (MIMO_CE_Method == 6)
            % 使用类似Walsh码的结构,得到不同位置导频符号的值
            
            if N_Tx_ant == 2
                if SwitchOrthogonalPilot == 1
                    %%%%%%%%%%%%%% Orthogonal design
                    if ant == 1
                        pilot_ofdm_sym(Idx_used,:) = [ tmp tmp ];
                    elseif ant == 2    
                        pilot_ofdm_sym(Idx_used,:) = [ tmp  -tmp ];
                    end
                elseif SwitchOrthogonalPilot == 0
                    %%%%%%%%%%%%%% Non-Orthogonal design
                    if ant == 1
                        pilot_ofdm_sym(Idx_used,:) = [ tmp1 tmp2 ];
                    elseif ant == 2    
                        pilot_ofdm_sym(Idx_used,:) = [ tmp3  tmp4 ];
                    end
                end
                
                
            elseif N_Tx_ant == 4
                if ant == 1
                    pilot_ofdm_sym(Idx_used,:) = [ tmp tmp tmp tmp];
                elseif ant == 2    
                    pilot_ofdm_sym(Idx_used,:) = [ tmp tmp -tmp -tmp];
                elseif ant == 3    
                    pilot_ofdm_sym(Idx_used,:) = [ tmp -tmp tmp -tmp];
                elseif ant == 4    
                    pilot_ofdm_sym(Idx_used,:) = [ -tmp tmp tmp -tmp];
                end
            end
            
        elseif  N_Tx_ant == 1
            pilot_ofdm_sym(Idx_used,:) = repmat( PN_seq( 1:length(Idx_used) ,ant) / sqrt(N_Tx_ant) , 1 ,N_pilot_sym_ts);
            
        end
        
        % 把导频OFDM符号放在输出的时隙中
        pilot_added(:,(ts-1)*(N_pilot_sym_ts + N_data_sym_ts) + Pos_pilot_sym, ant) = pilot_ofdm_sym;
        % 把数据OFDM符号放在输出的时隙中
        pilot_added(:,(ts-1)*(N_pilot_sym_ts + N_data_sym_ts) + Pos_data_sym, ant) = st_coded(:,(ts-1)*N_data_sym_ts + 1:ts*N_data_sym_ts,ant);
        % 把发送的已知导频放在known_pilot中返回   
        known_pilot(:,(ts-1)*N_pilot_sym_ts + 1 : ts*N_pilot_sym_ts , ant) = pilot_ofdm_sym;
        
    end
    
end

⌨️ 快捷键说明

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