Fetch the repository succeeded.
This action will force synchronization from openKylin/cybersectookits, which will overwrite any changes that you have made since you forked the repository, and can not be recovered!!!
Synchronous operation will process in the background and will refresh the page when finishing processing. Please be patient.
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;
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。