📄 get_rx_signal.m
字号:
%%%function [pkts, rx_sig] = get_rx_signal(start_sample,...stop_sample,pkts,packet_len,users,ep,symbol_start,TC,FS_CONT,...channel_p,DATA_LENGTH,RSCODE,L,...PACKET_LENGTH,BURST_LENGTH,SYMBOL_LENGTH,RX_BW,noise_var,samples,PLOT_DEBUG)%check which packets are active in the piece of rx signal we are looking atnum_packets = length(pkts);rx_sig = zeros(1,stop_sample-start_sample+1);for i = 1:num_packets% start_sample% stop_sample first_idx_pkt = start_sample - pkts(i).start + 1; last_idx_pkt = stop_sample - pkts(i).start + 1; if(~(first_idx_pkt > packet_len || last_idx_pkt < 1)) %make sure this is not true: packet ends before we start or starts after end rs = RSCODE; dl = DATA_LENGTH; if(RSCODE && ~(pkts(i).user == 1))%coding of non uoi packets is %a waste of time, so don't do it... rs = 0; dl = PACKET_LENGTH; end %check whether we already have a channel for this one if(isempty(pkts(i).channel)) %get the channel [norm_channel, pkts(i).ch_len] = get_compound_channel(TC,FS_CONT,... channel_p,PLOT_DEBUG); pwr_db = users(pkts(i).user).pwr; pwr_lin = 10^(pwr_db/10); pkts(i).channel = norm_channel .* sqrt(pwr_lin); end % %check whether we have a ths for this packet% if(isempty(pkts(i).ths))% if(~ep.rand_ths)%use the one from 802.15.4a% pkts(i).ths = ep.ths;% else %use a random THS% fprintf('random ths\n');% NHOP = SYMBOL_LENGTH/BURST_LENGTH/4;% pkts(i).ths = floor(NHOP*rand(1,PACKET_LENGTH));% end% end% %check whether we have data if(isempty(pkts(i).tx_bits)) % Get the data bit (coded or uncoded) [pkts(i).tx_bits,pkts(i).data_bits] = get_tx_bit(dl,rs,ep.interleaver_seed); end %create the packet chunk temp_start = max(1,first_idx_pkt); temp_stop = min(last_idx_pkt,packet_len); temp_sig = create_packet(temp_start,temp_stop,pkts(i).channel,... pkts(i).ch_len,channel_p.chip_span,pkts(i).tx_bits,users(pkts(i).user).ths,ep.scrambling,symbol_start,... users(pkts(i).user).code,... L,TC,FS_CONT,dl,rs,PACKET_LENGTH,BURST_LENGTH,... SYMBOL_LENGTH,samples,PLOT_DEBUG); %add to the signal starting_point = max(1,pkts(i).start - start_sample + 1); % len_rx = length(rx_sig)% len_temp = length(temp_sig)% last_index = starting_point+len_temp-1 rx_sig(starting_point:starting_point+length(temp_sig)-1) = rx_sig(starting_point:starting_point+length(temp_sig)-1) + temp_sig; endend%add noiserx_sig = rx_sig + get_noise(length(rx_sig),noise_var,samples.chip,TC,FS_CONT,RX_BW);%in fact this is not 100% correct, as the noise is%if we have overlapping blocks the overlapping part will not%twice see the same noise!!!% if(PLOT_DEBUG)% figure% plot(rx_sig,'r')% endreturn;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -