1 Star 0 Fork 323

宋国华/cybersectookits

forked from openKylin/cybersectookits 
加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
CDL_UMa_main.m 3.97 KB
一键复制 编辑 原始数据 按行查看 历史
鲁鑫 提交于 2023-05-11 08:16 . uma
clear
close all
clc
%% 初始设置
Moving_Speed = 0; % 设置设备移动速度
Sampling_Rate = 6.144e7; % 设置整体系统的采样率(Hz)
% 确定用户初始方位
Tx_Angle_B_o = [0 0 0]';
Rx_Angle_B_o = [0 0 0]';
phiLosAOA_B = 120;
%% 生成PBCH信号
sfn = 1; % System frame number
hrf = 1; % Half frame bit in SS/PBCH block transmissions, specified as 1 for the second half of a frame.
ibar_SSB = 0; % SSB位置
lssb = 8; % Number of candidate SS/PBCH blocks in a half frame, specified as 4, 8, or 64.
kssb = 30; % subcarrier offset
% Cell parameters
ncellid = 0; % physical layer cell identity number
ssbindex = 0;
v = mod(ssbindex,4);
K = 24; % Message length in bits
trblk = randi([0 1],24,1,'int8');
dmrsSym = nrPBCHDMRS(ncellid,ibar_SSB);% 生成PBCH解调参考信号
dmrsInd = nrPBCHDMRSIndices(ncellid); % 生成DMRS在网格中的位置指标
% Generate scrambled transport block
tpbchBits = nrBCH(trblk,sfn,hrf,lssb,kssb,ncellid); % 864 bits
% Generate PBCH symbols
modOut = nrPBCH(tpbchBits,ncellid,v); % 432 QPSK
% Generate PBCH location indice
pbchInd = nrPBCHIndices(ncellid);
%Generate an empty resource array for one transmitting antenna
% 生成载波(包含20个RB)默认子载波间隔15khz(caseA),14个OFDM符号(1个子帧,1ms)
carrier = nrCarrierConfig('NSizeGrid',20);
txGrid = nrResourceGrid(carrier); % 根据载波和生成资源网格,14个OFDMsymbol
txGrid(pbchInd) = modOut; % 将PBCH信号映射到网格中的相应位置
txGrid(dmrsInd) = dmrsSym; % 将DM-RS信号映射到网格上的相应位置
p_s = 0;
% p_an = 0;
for ii_row = 1:240
p_s = p_s + mean(abs(txGrid(ii_row,:)).^2) / 240;
% p_an = p_an + mean(abs(txGrid_an(ii_row,:)).^2) / 240;
end
%Perform OFDM modulation
[txWaveform_OFDM,info_OFDM] = nrOFDMModulate(carrier,txGrid,'SampleRate',Sampling_Rate); %1ms可以采集Sampling_Rate/1000个点
txWaveform = txWaveform_OFDM;
%% 构建cdl-UMa_Los信道
Channel_Seed_B = floor(rand(1) * 1000);
% 生成构建cdl-UMa_Los信道所的需参数
[fc_B,tauNLos_B,PNLosdb_B,PhiAOA_B,PhiAOD_B,PhiZOA_B,PhiZOD_B,K_B,CASDNLos_B,...
CASANLos_B,CZSDNLos_B,CZSANLos_B,XPRNLos_B] = CDL_Channel_UMa_Los_generate(phiLosAOA_B);
% % 生成构建cdl-UMa_NLos信道所的需参数
% [fc_B,tauNLos_B,PNLosdb_B,PhiAOA_B,PhiAOD_B,PhiZOA_B,PhiZOD_B,K_B,CASDNLos_B,...
% CASANLos_B,CZSDNLos_B,CZSANLos_B,XPRNLos_B] = CDL_Channel_UMa_NLos_generate(phiLosAOA_B);
% 构建cdl-UMa_Los信道,并生成接收信号
[rxWaveform_B_U,cdl_B] = Process_CDL_Channel_UMa(txWaveform,Sampling_Rate,Tx_Angle_B_o,Rx_Angle_B_o,...
Moving_Speed,fc_B,Channel_Seed_B,tauNLos_B,PNLosdb_B,PhiAOA_B,PhiAOD_B,PhiZOA_B,PhiZOD_B,K_B,CASDNLos_B,CASANLos_B,...
CZSDNLos_B,CZSANLos_B,XPRNLos_B);
%% 解调接收信号
E = 864; % Rate matched output length, E <= 8192
L = 8; % List length, a power of two, [1 2 4 8]
crcLen = 24; % Number of CRC bits for DL, Section 5.1, [6]
SNR_dB = 30;
SNR = 10.^(SNR_dB/10);
%% 生成加性噪声
noiseVar = p_s/SNR;
noise_B = sqrt(noiseVar/2)*(randn(Sampling_Rate/1000,32)+1i*randn(Sampling_Rate/1000,32));
rxWaveform_B = rxWaveform_B_U + noise_B;
rxGrid_B = nrOFDMDemodulate(carrier,rxWaveform_B,"SampleRate",Sampling_Rate);
% 进行信道估计
hEstGrid_B = nrChannelEstimate(rxGrid_B,dmrsInd,dmrsSym);
% Extract symbols from received signals and generate channel estimate grids
[pbchRxSym_B,pbchHest_B] = nrExtractResources(pbchInd,rxGrid_B,hEstGrid_B);
% MMSE equalization
[pbchEqSym_B,csi] = nrEqualizeMMSE(pbchRxSym_B,pbchHest_B,noiseVar);
% PBCH demodulate
[rpbchBits_B,demod_B] = nrPBCHDecode(pbchEqSym_B,ncellid,v);
% Return unscrambled transport block
[~,errFlag_B,rxtrblk_B,rxSFN4lsb_B,rxHRF_B,rxKssb_B] = nrBCHDecode( ...
double(1-2*(rpbchBits_B < 0)),L,lssb,ncellid);
% Test bit error rate
numBitErrs_B = biterr(int8(rxtrblk_B),trblk) / K;
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/sghshare/cybersectookits.git
git@gitee.com:sghshare/cybersectookits.git
sghshare
cybersectookits
cybersectookits
master

搜索帮助