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

📄 single_packet.m

📁 国外大学的同志作出来的好程序
💻 M
字号:
function [packet_rf_data, info_bits, coded_bits, packet_baseband_data]=single_packet(sim);
%Generate wave for signel packet.
%
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%source bits generation
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
info_bits=gen_sourcebits(sim);


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%channe coding(optional)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%tcm/convolutional coding
if strcmp(lower(sim.coding_type), '802_15_3_tcm'),
    trellis=ieee802_15_3_tcm_code(sim.mapping_type);
    coded_bits=trellis_encoder(info_bits, trellis);
elseif strcmp(lower(sim.coding_type), '802_16_tcm')
    disp('Coming soon...'); return;
    coded_bits=info_bits;
elseif ~isempty(findstr(lower(sim.coding_type), '802_16_ctc')),
    [coded_bits, info_bits]=ieee802_16_punct_ctc(info_bits, sim.coding_type, sim.coding_rate);
elseif isempty(sim.coding_type),
    coded_bits=info_bits;
end


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%interleaver(optional) %last step before complex domain
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if strcmp(lower(sim.interleaver), 'random'),
    woven_bits= randintrlv(coded_bits, sim.interleaver_val);
elseif isempty(sim.interleaver),
    woven_bits=coded_bits;
end


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%mapping
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
constell=get_constell(sim.mapping_type);
symbols=mapping(woven_bits, constell, sim.mapping_msb);


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%multiplexing (optional)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if ~isempty(sim.multiplex_type)
    frame_length=round(sim.frame_time*sim.symbol_rate);
    mx_symbols=multiplexing(symbols, frame_length);
else
    mx_symbols=symbols;
end

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%generate/add prefix and appendix (optional)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if ~isempty(sim.prefix_type),
    [prefix, appendix]=get_affix(mx_symbols, sim);
    frame_data_len=round(sim.frame_data_time*sim.symbol_rate);
    [frames, frames_num]=add_affix(mx_symbols, frame_data_len, prefix, appendix);
else
    frames=mx_symbols;
end


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%generate and preamble (optional)
%Last step before passband processing
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
if ~isempty(sim.preamble_type),
    preamble_len=round(sim.preamble_time*sim.symbol_rate);
    preamble=get_preamble(sim.preamble_type, preamble_len);
    packet_data=[preamble; frames];
else
    packet_data=frames;
end
packet_baseband_data=packet_data;


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%carrier modulations.
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
ps_filter=get_psfilter(sim);
packet_rf_data=carrier_modulations(packet_data, sim.carrier_freq, sim.sampling_rate, sim.symbol_rate, ps_filter);


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%add blank, lfm (optional)
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
blank_len=round(sim.blank_time*sim.sampling_rate);
blank=zeros(blank_len, size(packet_rf_data, 2));
if ~isempty(sim.lfm_type),
    lfm_seq=get_lfm(sim);
    packet_rf_data=[lfm_seq; packet_rf_data];
end
packet_rf_data=[blank; packet_rf_data];

⌨️ 快捷键说明

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