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

📄 wlan_transmitter.txt

📁 WLAN仿真-发送机 wlan No Comments 设置完系统参数后
💻 TXT
字号:
%%%%%%%%%%%%%%%%%%%%  Transmitter %%%%%%%%%%%%%%%%%%%%%%%%
%--- 1. generate random data symbol--------------------------
tx_bits=randsrc(PacketLength, 1, 0:M_type-1);
mod_syms = qammod(tx_bits,M_type,0,'gray');
% normalize power to 1
mod_syms = mod_syms./sqrt(var(mod_syms));

%--- 2. generate ofdm symbol ------------------------------
n_ofdm_syms = PacketLength/NumDataSubc;
mod_ofdm_syms = zeros(NumSubc, n_ofdm_syms);
mod_ofdm_syms(DataSubcPatt,:) = reshape(mod_syms, NumDataSubc, n_ofdm_syms);

%--- 3. generate pilot scrambling pattern ----------------------------
scramble_patt = repmat(PilotScramble,1,ceil(n_ofdm_syms/length(PilotScramble)));
scramble_patt = scramble_patt(1:n_ofdm_syms);

%--- 4. insert the pilot into the ofdm symbol ---------------------------
mod_ofdm_syms(PilotSubcPatt,:) = repmat(scramble_patt, NumPilotSubc,1).* ...
   repmat(PilotSubcSymbols, 1, n_ofdm_syms);

%--- 5. add dc and guard subcarriers -------------------------
syms_into_ifft = zeros(64, n_ofdm_syms);
syms_into_ifft(UsedSubcPatt,:)=mod_ofdm_syms;

%--- 6. generate time domain data symbol -------------------
ifft_out = ifft(syms_into_ifft);
% add Cycle prefix
ofdm_time_syms = [ifft_out(end-16+1:end,:); ifft_out];
%--- 7. overlap add and window the data symbol ------------
ofdm_time_syms = [ofdm_time_syms; ofdm_time_syms(1,:)].*repmat(data_win,1,n_ofdm_syms);
ofdm_time_signal=ofdm_time_syms(:,1);
for idx=1:n_ofdm_syms-1
ofdm_time_signal = [ofdm_time_signal(1:end-1); ...
    ofdm_time_syms(81,idx)+ofdm_time_syms(1,idx+1); ...
    ofdm_time_syms(2:81,idx+1)];
end
ofdm_time_signal=ofdm_time_signal.';

%--- 8. generate time domain short preamble symbol -----------
short_tr_symbol = zeros(64,1);
short_tr_symbol(UsedSubcPatt,:)=ShortTrainingSymbols.';
short_tr_time_sym = ifft(short_tr_symbol).';
% Pick one short training symbol
Strs = short_tr_time_sym(1:16);
% extend to ten short training symbols and window
short_trs=[Strs Strs Strs Strs Strs Strs Strs Strs Strs Strs];
short_trs=[short_trs short_trs(1)].*trs_win;

%--- 9. generate time domain long preamble symbol -----------
long_tr_symbol = zeros(64,1);
long_tr_symbol(UsedSubcPatt,:)=LongTrainingSymbols.';
long_tr_time_sym = ifft(long_tr_symbol).';
% extend to two long training symbols and window
long_trs_signal = [long_tr_time_sym(64-2*16+1:64) long_tr_time_sym long_tr_time_sym];
long_trs_signal = [long_trs_signal long_trs_signal(1)].*trs_win;
% overlap add the short preamble and long preamble
preamble = [short_trs(1:end-1) short_trs(end)+long_trs_signal(1) long_trs_signal(2:end)];

%--- 10. compose the preamble and the data symbol into one packet  --------
Tx_signal = [preamble(1:end-1) preamble(end)+ofdm_time_signal(1) ofdm_time_signal(2:end)].*64/sqrt(64);

% --- 11. upsampling -----------------------------------------------------
Tx_up = upsample(Tx_signal,100).*sqrt(100);;

b=rcosfir(0.25,[-1*8,8],100,1,'normal');
b=b./sum(b);
Tx_signal_up =conv(b,Tx_up);


clear mod_ofdm_syms scramble_patt syms_into_ifft ifft_out ofdm_time_syms ofdm_time_signal;
clear short_tr_symbol short_tr_time_sym short_trs long_tr_symbol long_tr_time_sym long_trs_signal;
clear idx Strs Tx_up; 

⌨️ 快捷键说明

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