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

📄 preamble_gen.m

📁 抽头长度可变的802.11n信道估计方法.802.11n即将出台
💻 M
字号:
function [t_preamble,t_preamble_cp,f_preamble,N_LTF] = preamble_gen(N_STS)
clear all;
close all;

% 生成HT-LTF(HT long training field)
%function preamble=preamble_gen(GuardInterval,N_STS)

% GuardInterval:保护间隔,802.11n中GuardInterval = 16
GuardInterval = 16;
% n_tx_antenna:发送天线数,802.11n中n_tx_antenna = 1,2,3,4
% N_STS:空时流的个数,802.11n中N_STS = 1,2,3,4
N_STS = 2;
% N_LTF:前导符号个数(当N_ELTF==0)
if N_STS == 1||N_STS == 2||N_STS == 4
    N_LTF = N_STS;
elseif N_STS ==3;
    N_LTF = 4;
end
% N_ESS:扩展时间流的个数,802.11n中N_STS = 0,1,2,3。现只考虑N_ESS = 0的情况。
% i_STS:前导符号序号,802.11n中i_STS = 1:N_LTF
%--------------------------------------------------------------------------

% 20MHZ,57个点
HTLTF_20 = [1 1 1 1 -1 -1 1 1 -1 1 -1 1 1 1 1 1 1 -1 -1 1 1 -1 1 -1 1 1 1 1 0 1 -1 -1 1 1 -1 1 -1 1 -1 -1 -1 -1 -1 1 1 -1 -1 1 -1 1 -1 1 1 1 1 -1 -1];
% 40MHZ,116个点
% HTLTF_40 = [1 1 -1 -1 1 1 -1 1 -1 1 1 1 1 1 1 -1 -1 1 1 -1 1 -1 1 1 1 1 1 1 -1 -1 1 1 -1 1 -1 1 -1 -1 -1 -1 -1 1 1 -1 -1 1 -1 1 -1 1 1 1 1 -1 -1 -1 1 0 0 0 -1 1 1 -1 1 1 -1 -1 1 1 -1 1 -1 1 1 1 1 1 1 1 -1 1 1 -1 1 -1 1 1 1 1 1 1 -1 -1 1 1 -1 1 -1 1 -1 -1 -1 -1 -1 1 1 -1 -1 1 -1 1 -1 1 1 1 1];

P_HTLTP = [1 -1 1 1
    1 1 -1 1
    1 1 1 -1
    -1 1 1 1 ];

% 考虑最简单的情况:Qk为单位阵,此时N_STS = n_tx_antenna
Qk = eye(N_STS);
n_tx_antenna = N_STS;
M = 64;%ifft点数
N = 16;%16-qam
%--------------------------------------------------------------------------
if N_STS == 1 % n_tx_antenna == 1 ,只有一个前导符号
    i_STS = 1;% 只有一个前导符号
    for i=1:57,
        %temp = zeros(4,57);
        a = HTLTF_20(i);
        temp(:,i) = a*P_HTLTP(:,i_STS);
    end
    % csd循环移位
    csd_temp(1,:) = [temp(1,1:28),temp(1,30:57)];
    %-----------------------------
    f_preamble_temp = Qk*csd_temp(1:N_STS,:);%每行56点
    %-----------------------------
    %补0
    f_preamble(1,:) = [zeros(1,1),f_preamble_temp(1,29:56),zeros(1,7),f_preamble_temp(1,1:28)];%每行64点
    %ifft
    t_preamble(1,:) = ifft(f_preamble(1,:),M)*sqrt(M);%每行64点*M 
    %add cp
    t_preamble_cp(1,:) =  [t_preamble(1,65-GuardInterval:64), t_preamble(1,:)];%每行80点

elseif N_STS ==2 % n_tx_antenna == 2,2个前导符号
    for i_STS = 1; % 第一个前导符号
        for i=1:57,
        a = HTLTF_20(i);
        temp1(:,i) = a*P_HTLTP(:,i_STS);
        end
    end
    % csd循环移位
    csd_temp1(1,:) = [temp1(1,1:28),temp1(1,30:57)];
    csd_temp1(2,:) = [temp1(2,50:57),temp1(2,1:28),temp1(2,30:49)];
    %---------------------
    f_preamble_temp1 = Qk*csd_temp1(1:N_STS,:);%每行56点
    %---------------------
    %补0
    for i = 1:N_STS,
        f_preamble1(i,:) = [zeros(1,1),f_preamble_temp1(i,29:56),zeros(1,7),f_preamble_temp1(i,1:28)];%每行64点
    %ifft
        t_preamble1(i,:) = ifft(f_preamble1(i,:),M)*sqrt(M);%每行64点*M  /n_tx_antenna
    %add cp
        t_preamble_cp1(i,:) =  [t_preamble1(i,65-GuardInterval:64), t_preamble1(i,:)];%每行80点
    end
    %----------------------------------------------------------------------
    for i_STS = 2; % 第二个前导符号
        for i=1:57,
        a = HTLTF_20(i);
        temp2(:,i) = a*P_HTLTP(:,i_STS);
        end
    end
    % csd循环移位
    csd_temp2(1,:) = [temp2(1,1:28),temp2(1,30:57)];
    csd_temp2(2,:) = [temp2(2,50:57),temp2(2,1:28),temp2(2,30:49)];
    %---------------------
    f_preamble_temp2 = Qk*csd_temp2(1:N_STS,:);%每行56点
    %---------------------
    %补0
    for i = 1:N_STS,
        f_preamble2(i,:) = [zeros(1,1),f_preamble_temp2(i,29:56),zeros(1,7),f_preamble_temp2(i,1:28)];%每行64点
    %ifft
        t_preamble2(i,:) = ifft(f_preamble2(i,:),M)*sqrt(M);%每行64点*M  /n_tx_antenna
    %add cp
        t_preamble_cp2(i,:) =  [t_preamble2(i,65-GuardInterval:64), t_preamble2(i,:)];%每行80点
    end
    %2个前导符号合成--------------------------------------------------------
    c_t ={t_preamble1  t_preamble2 };
    t_preamble = cell2mat(c_t);%2*128
    
    c_t_cp ={t_preamble_cp1  t_preamble_cp2 };
    t_preamble_cp = cell2mat(c_t_cp);%2*160
    
    c_f ={f_preamble1  f_preamble2};
    f_preamble = cell2mat(c_f);%2*128
    
elseif N_STS ==3||N_STS ==4% n_tx_antenna == 3||n_tx_antenna == 4,4个前导符号
    for i_STS = [1:N_LTF];
    end
end



%--------------------------------------------------------------------------
figure()
if N_STS == 2
    t_preamble_tx1 = t_preamble(1,:);
    subplot(2,1,1),stem(abs(t_preamble_tx1'));
    title('preamble of tx1');
    xlabel('Time Index'); ylabel('T-preamble Value');
    xlim([1 128]);
    grid on;
    
    t_preamble_tx2 = t_preamble(2,:);
    subplot(2,1,2),stem(abs(t_preamble_tx2'));
    title('preamble of tx2');
    xlabel('Time Index'); ylabel('T-preamble Value');
    xlim([1 128]);
    grid on;
elseif N_STS == 1
    t_preamble_tx1 = t_preamble(1,:);
    stem(abs(t_preamble_tx1'));
    title('preamble of tx1');
    xlabel('Time Index'); ylabel('T-preamble Value');
    xlim([1 64]);
    grid on;
end
%eval(['print -djpeg -r300 ', 'T-preamble','-tx',num2str(N_STS),'.jpg;']);
close;


figure()
if N_STS == 2
    f_preamble_tx1 = f_preamble(1,:);
    subplot(2,1,1),stem(f_preamble_tx1','.');
    title('preamble of tx1');
    xlabel('Frequency Index'); ylabel('F-preamble Value');
    xlim([1 128]);
    grid on;
    
    f_preamble_tx2 = f_preamble(2,:);
    subplot(2,1,2),stem(f_preamble_tx2','.');
    title('preamble of tx2');
    xlabel('Frequency Index'); ylabel('F-preamble Value');
    xlim([1 128]);
    grid on;
elseif N_STS == 1
    f_preamble_tx1 = f_preamble(1,:);
    stem(f_preamble_tx1','.');
    title('preamble of tx1');
    xlabel('Frequency Index'); ylabel('F-preamble Value');
    xlim([1 64]);
    grid on;
end
%eval(['print -djpeg -r300 ', 'F-preamble','-tx',num2str(N_STS),'.jpg;']);
close;



% t_preamble3 = t_preamble(3,:);
% subplot(4,1,3),stem(abs(t_preamble3'));
% title('preamble of tx3');
% xlabel('Time Index'); ylabel('preamble Value');
% 
% t_preamble4 = t_preamble(4,:);
% subplot(4,1,4),stem(abs(t_preamble4'));
% title('preamble of tx4');
% xlabel('Time Index'); ylabel('preamble Value');






⌨️ 快捷键说明

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