function [optBeamPairIdxMatTrain,rsrpMatTrain] = ...
hGenDataMIMOScatterChan(mode,locationMat,prm,txBurst,arrayTx,arrayRx,seed)
% hGenDataMIMOScatterChan Generate data for neural network based beam
% selection example
%
% See also NeuralNetworkBeamSelectionExample, NewRadioSSBBeamSweepingExample.
% Copyright 2022 The MathWorks, Inc.
disp(['Generating ' mode ' data...'])
rng(seed); % Set RNG state for repeatability
c = physconst('LightSpeed'); % Propagation speed
if strcmp(mode, 'training')
cnt = prm.NDiffLocTrain;
else % test
cnt = prm.NDiffLocTest;
end
%% Burst Generation
% Configure an nrDLCarrierConfig object to use the synchronization signal
% burst parameters and to disable other channels. This object will be used
% by nrWaveformGenerator to generate the SS burst waveform.
cfgDL = configureWaveformGenerator(prm,txBurst);
% Get OFDM information
ofdmInfo = nrOFDMInfo(cfgDL.SCSCarriers{1}.NSizeGrid,prm.SCS);
sampleRate = ofdmInfo.SampleRate;
% Generate burst waveform
burstWaveform = nrWaveformGenerator(cfgDL);
%% Transmit-End Beam Sweeping
% Transmit beam angles in azimuth and elevation, equi-spaced
azBW = beamwidth(arrayTx,prm.CenterFreq,'Cut','Azimuth');
elBW = beamwidth(arrayTx,prm.CenterFreq,'Cut','Elevation');
txBeamAng = hGetBeamSweepAngles(prm.numBeams,prm.TxAZlim,prm.TxELlim, ...
azBW,elBW,prm.ElevationSweep);
% For evaluating transmit-side steering weights
SteerVecTx = phased.SteeringVector('SensorArray',arrayTx, ...
'PropagationSpeed',c);
% Get the set of OFDM symbols occupied by each SSB
numBlocks = length(txBurst.TransmittedBlocks);
burstStartSymbols = ssBurstStartSymbols(txBurst.BlockPattern,numBlocks);
burstStartSymbols = burstStartSymbols(txBurst.TransmittedBlocks==1);
burstOccupiedSymbols = burstStartSymbols.' + (1:4);
% Apply steering per OFDM symbol for each SSB
gridSymLengths = repmat(ofdmInfo.SymbolLengths,1,cfgDL.NumSubframes);
% repeat burst over numTx to prepare for steering
strTxWaveform = repmat(burstWaveform,1,prm.NumTx)./sqrt(prm.NumTx);
for ssb = 1:prm.numBeams
% Extract SSB waveform from burst
blockSymbols = burstOccupiedSymbols(ssb,:);
startSSBInd = sum(gridSymLengths(1:blockSymbols(1)-1))+1;
endSSBInd = sum(gridSymLengths(1:blockSymbols(4)));
ssbWaveform = strTxWaveform(startSSBInd:endSSBInd,1);
% Generate weights for steered direction
wT = SteerVecTx(prm.CenterFreq,txBeamAng(:,ssb));
% Apply weights per transmit element to SSB
strTxWaveform(startSSBInd:endSSBInd,:) = ssbWaveform.*(wT');
end
%% Receive-End Beam Sweeping and Measurement
% Receive beam angles in azimuth and elevation, equi-spaced
azBW = beamwidth(arrayRx,prm.CenterFreq,'Cut','Azimuth');
elBW = beamwidth(arrayRx,prm.CenterFreq,'Cut','Elevation');
rxBeamAng = hGetBeamSweepAngles(prm.numBeams,prm.RxAZlim,prm.RxELlim, ...
azBW,elBW,prm.ElevationSweep);
% For evaluating receive-side steering weights
SteerVecRx = phased.SteeringVector('SensorArray',arrayRx, ...
'PropagationSpeed',c);
% AWGN level
SNR = 10^(prm.SNRdB/20); % Convert to linear gain
N0 = 1/(sqrt(2.0*prm.NumRx*double(ofdmInfo.Nfft))*SNR); % Noise Std. Dev.
% Generate a reference grid for timing correction
% assumes an SSB in first slot
carrier = nrCarrierConfig('NCellID',prm.NCellID);
carrier.NSizeGrid = cfgDL.SCSCarriers{1}.NSizeGrid;
carrier.SubcarrierSpacing = prm.SCS;
pssRef = nrPSS(carrier.NCellID);
pssInd = nrPSSIndices;
ibar_SSB = 0;
pbchdmrsRef = nrPBCHDMRS(carrier.NCellID,ibar_SSB);
pbchDMRSInd = nrPBCHDMRSIndices(carrier.NCellID);
pssGrid = zeros([240 4]);
pssGrid(pssInd) = pssRef;
pssGrid(pbchDMRSInd) = pbchdmrsRef;
refGrid = zeros([12*carrier.NSizeGrid ofdmInfo.SymbolsPerSlot]);
burstOccupiedSubcarriers = carrier.NSizeGrid*6 + (-119:120).';
refGrid(burstOccupiedSubcarriers, ...
burstOccupiedSymbols(1,:)) = pssGrid;
%% Processing loop for each location
numReps = prm.NRepeatSameLoc;
rsrpMat = zeros(prm.numBeams,prm.numBeams,cnt);
% Each row represent a (numBeams*numBeams)-dim sample's output (containing
% a single "1" at the optimal beam pair index)
optBeamPairIdxMat = zeros(numReps,cnt,prm.numBeams*prm.numBeams);
fprintf(' Total iterations: %d\n', cnt*numReps)
% Uncomment line below to use Parallel Computing Toolbox instead
%parfor locIdx = 1:cnt
for locIdx = 1:cnt
posRx = locationMat((locIdx-1)*numReps+1, :)'; % Update rx position
toRxRange = rangeangle(prm.posTx,posRx);
spLoss = fspl(toRxRange,prm.lambda); % Free space path loss
% Configure channel
% one per location, repeated for numReps use
channel = phased.ScatteringMIMOChannel;
channel.PropagationSpeed = c;
channel.CarrierFrequency = prm.CenterFreq;
channel.SampleRate = sampleRate;
if posRx(2) >= prm.posTx(2)
channel.SimulateDirectPath = true;
else
channel.SimulateDirectPath = false;
end
channel.ChannelResponseOutputPort = true;
channel.Polarization = 'None';
channel.TransmitArray = arrayTx;
channel.TransmitArrayPosition = prm.posTx;
channel.ReceiveArray = arrayRx;
channel.ReceiveArrayPosition = posRx;
channel.ScattererSpecificationSource = 'Property';
channel.ScattererPosition = prm.ScatPos;
channel.ScattererCoefficient = ones(1,size(prm.ScatPos,2));
% Get maximum channel delay
[~,~,tau] = channel(complex(randn(sampleRate*1e-3,prm.NumTx), ...
randn(sampleRate*1e-3,prm.NumTx)));
maxChDelay = ceil(max(tau)*sampleRate);
% Receive gain in linear terms, to compensate for the path loss
rxGain = 10^(spLoss/20);
for repeatIdx = 1:numReps
idx = (locIdx-1)*numReps + repeatIdx;
if mod(idx, 10) == 0
disp([' Iteration count = ' num2str(idx)]);
end
% Loop over all receive beams
rsrp = zeros(prm.numBeams,prm.numBeams);
for rIdx = 1:prm.numBeams
% Fading channel, with path loss
txWave = [strTxWaveform; zeros(maxChDelay,size(strTxWaveform,2))];
fadWave = channel(txWave);
% Receive gain, to compensate for the path loss
fadWaveG = fadWave*rxGain;
% Add WGN
noise = N0*complex(randn(size(fadWaveG)),randn(size(fadWaveG)));
rxWaveform = fadWaveG + noise;
% Generate weights for steered direction
wR = SteerVecRx(prm.CenterFreq,rxBeamAng(:,rIdx));
% Apply weights per receive element
if strcmp(prm.FreqRange, 'FR1')
strRxWaveform = rxWaveform.*(wR');
else % for FR2, combine signal from antenna elements
strRxWaveform = rxWaveform*conj(wR);
end
% Correct timing
offset = nrTimingEstimate(carrier, ...
strRxWaveform(1:sampleRate*1e-3,:),refGrid*wR(1)');
if offset > maxChDelay
offset = 0;
end
strRxWaveformS = strRxWaveform(1+offset:end,:);
% OFDM Demodulate
rxGrid = nrOFDMDemodulate(carrier,strRxWaveformS);
% Loop over all SSBs in rxGrid (transmit end)
for tIdx = 1:prm.numBeams
% Get each SSB grid
rxSSBGrid = rxGrid(burstOccupiedSubcarriers, ...
burstOccupiedSymbols(tIdx,:),:);
% Make measurements, store per receive, transmit beam
measuredRsrp = measureSSB(rxSSBGrid,prm.RSRPMode,prm.NCellID);
rsrp(rIdx,tIdx) = measuredRsrp;
end
end
rsrpMat(:,:,locIdx) = rsrpMat(:,:,locIdx) + rsrp;
%% Beam Determination
[~,i] = max(rsrp,[],'all','linear'); % First occurence is output
% i is column-down first (for receive), then across columns (for transmit)
[rxBeamID,txBeamID] = ind2sub([prm.numBeams prm.numBeams],i(1));
optBeamIdx = (txBeamID-1)*prm.numBeams+rxBeamID;
optBeamVec = zeros(prm.numBeams*prm.numBeams,
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
一、前言 此示例说明如何使用神经网络来减少光束选择任务中的开销。在此示例中,您仅使用接收方的位置,而不是通信信道的知识。您可以通过在选定的波束对中进行搜索来减少波束扫掠开销,而不是对所有波束对进行详尽的波束搜索K光束对。考虑到一个总共有16个光束对的系统,本例中的仿真结果表明,所设计的机器学习算法只需对一半的光束对进行详尽搜索,就可以达到90%的准确率。 二、介绍 为了实现毫米波(mmWave)通信,必须使用波束管理技术,因为在高频下会经历高路径损耗和阻塞。波束管理是一组第 1 层(物理层)和第 2 层(介质访问控制)程序,用于建立和保留最佳波束对(发射波束和相应的接收波束)以实现良好的连接 [1]。 此示例考虑在用户设备 (UE) 和接入网络节点 (gNB) 之间建立连接时的波束选择过程。在5G NR中,初始接入的波束选择程序包括波束扫描,这需要对发射器和接收器侧的所有波束进行详尽搜索,然后选择提供最强参考信号接收功率(RSRP)的波束对。由于毫米波通信需要许多天线元件,这意味着许多波束,因此对所有波束进行详尽搜索的计算成本很高,并且增加了初始访问时间。
资源推荐
资源详情
资源评论
收起资源包目录
使用matlab基于神经网络进行光束选择.rar (8个子文件)
使用matlab基于神经网络进行光束选择
hGenDataMIMOScatterChan.m 12KB
nnBS_TrainingData.mat 25KB
NeuralNetworkBeamSelectionExample.mlx 30KB
hGetBeamSweepAngles.m 3KB
nnBS_TestData.mat 13KB
nnBS_prm.mat 863B
nnBS_trainedNetwWeighting.mat 112KB
nnBS_trainedNet.mat 112KB
共 8 条
- 1
资源评论
珞瑜·
- 粉丝: 10w+
- 资源: 500
下载权益
C知道特权
VIP文章
课程特权
开通VIP
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功