【OFDM通信】基于深度学习的OFDM系统信号检测附matlab代码

 1 简介

提供了一种基于深度学习的时变OFDM系统信号检测方法,生成信号检测网络模型输入数据集,构建一个信号检测网络模型,在网络训练前需预设好训练和测试参数,采用在线生成训练数据和测试数据的方式训练网络,测试数据喂入信号检测网络,信号检测网络模型根据喂入的特征向量,产生预测出的发送数据比特,与真实的发送数据比特进行对比,测试网络当前的性能.本发明于针对快速时变OFDM系统,结合深度学习方法,利用循环神经网络处理时间序列的优势,简化了接收机架构,成功实现信号的解调,改进了快速时变OFDM系统中的信号检测性能,本发明有效减小了系统实现复杂度,同时也提升了系统整体的误比特率性能.

2 部分代码

function ReceivedPacket = genTransmissionReceptionOFDM(TransmittedFrame,LengthCP,h,NoiseVar)
% This function is to model the transmission and reception process in OFDM systems. 

% Extract parameters
[NumSym,NumSC,NumPacket] = size(TransmittedFrame);

%% Transmitter

PhaseShift = exp(-1j*rand(1,NumPacket)*2*pi);

for p = 1:NumPacket
                                  
    % 1. IFFT
    x1 = ifft(TransmittedFrame(:,:,p),NumSC,2); 
    
    % 2. Inserting CP
    x1_CP = [x1(:,NumSC-LengthCP+1:end) x1]; 
        
    % 3. Parallel to serial transformation
    x2 = x1_CP.';
    x = x2(:);
    
    % 4. Channel filtering
    y_conv = conv(h*PhaseShift(p),x);
    y(:,p) = y_conv(1:length(x)); 
end 
                        
%% Adding noise 

SeqLength = size(y,1);
 
% Calculate random noise in time domain 
NoiseF = sqrt(NoiseVar)/sqrt(2).*(randn(NumPacket,NumSC)+1j*randn(NumPacket,NumSC)); % Frequency-domain noise
NoiseT = sqrt(SeqLength)*sqrt(SeqLength/NumSC)*ifft(NoiseF,SeqLength,2); % Time-domain noise

% Adding noise
y = y+NoiseT.'; 

%% Receiver

ReceivedPacket = zeros(NumPacket,NumSym,NumSC); 
    
for p = 1:NumPacket
     
    % 1. Serial to parallem transformation
    y1 = reshape(y(:,p),NumSC+LengthCP,NumSym).'; 

    % 2. Removing CP
    y2 = y1(:,LengthCP+1:LengthCP+NumSC);

    % 3. FFT, # x NymSym x 64
    ReceivedPacket(p,:,:) = fft(y2,NumSC,2); % NumSym x 64
        
end 

ReceivedPacket = permute(ReceivedPacket,[2,3,1]); 

%% Testing

% This script
%   1. generates testing data for each SNR point;
%   2. calculates the symbol error rate (SER) based on deep learning (DL), 
%   least square (LS) and minimum mean square error (MMSE).

%% Clear workspace

clear variables;
close all;

%% Load common parameters and the trained NN

load('SimParametersPilot64.mat');
load('TrainedNetPilot64.mat');

%% Other simulation parameters

NumPilot = length(FixedPilot);
PilotSpacing = NumSC/NumPilot;
NumOFDMsym = NumPilotSym+NumDataSym;
NumClass = length(Label);
NumPath = length(h);

% Load pre-calculated channel autocorrelation matrix for MMSE estimation
% This autocorrelation matrix is calculated in advance using the 3GPP
% channel model, which can be replaced accordingly.
load('RHH.mat');

%% SNR range

Es_N0_dB = 0:2:20; % Es/N0 in dB
Es_N0 = 10.^(Es_N0_dB./10); % linear Es/N0
N0 = 1./Es_N0;
NoiseVar = N0./2;

%% Testing data size

NumPacket = 10000; % Number of packets simulated per iteration

%% Simulation

% Same pilot sequences used in training and testing stages
FixedPilotAll = repmat(FixedPilot,1,1,NumPacket); 

% Number of Monte-Carlo iterations
NumIter = 1;

% Initialize error rate vectors
SER_DL = zeros(length(NoiseVar),NumIter);
SER_LS = zeros(length(NoiseVar),NumIter);
SER_MMSE = zeros(length(NoiseVar),NumIter);

for i = 1:NumIter
    
    for snr = 1:length(NoiseVar)
        
        %% 1. Testing data generation
        
        noiseVar = NoiseVar(snr);
                
        % OFDM pilot symbol (can be interleaved with random data symbols)
        PilotSym = 1/sqrt(2)*complex(sign(rand(NumPilotSym,NumSC,NumPacket)-0.5),sign(rand(NumPilotSym,NumSC,NumPacket)-0.5)); 
        PilotSym(1:PilotSpacing:end) = FixedPilotAll;
    
        % OFDM data symbol
        DataSym = 1/sqrt(2)*complex(sign(rand(NumDataSym,NumSC,NumPacket)-0.5),sign(rand(NumDataSym,NumSC,NumPacket)-0.5)); 
    
        % Transmitted OFDM frame
        TransmittedPacket = [PilotSym;DataSym];
        
        % Received OFDM frame
        ReceivedPacket = genTransmissionReceptionOFDM(TransmittedPacket,LengthCP,h,noiseVar);
        
        % Collect the data labels for the selected subcarrier
        DataLabel = zeros(size(DataSym(:,idxSC,:)));
        for c = 1:NumClass
            DataLabel(logical(DataSym(:,idxSC,:) == 1/sqrt(2)*Mod_Constellation(c))) = Label(c);
        end
        DataLabel = squeeze(DataLabel); 

        % Testing data collection
        XTest = cell(NumPacket,1);
        YTest = zeros(NumPacket,1);       
        for c = 1:NumClass
            [feature,label,idx] = getFeatureAndLabel(real(ReceivedPacket),imag(ReceivedPacket),DataLabel,Label(c));
            featureVec = mat2cell(feature,size(feature,1),ones(1,size(feature,2))); 
            XTest(idx) = featureVec;
            YTest(idx) = label;
        end
        YTest = categorical(YTest);
        
        %% 2. DL detection
        
        YPred = classify(Net,XTest,'MiniBatchSize',MiniBatchSize);
        SER_DL(snr,i) = 1-sum(YPred == YTest)/NumPacket;
        
        %% 3. LS & MMSE detection
        
        % Channel estimation
        wrapper = @(x,y) performChanEstimation(x,y,RHH,noiseVar,NumPilot,NumSC,NumPath,idxSC);
        ReceivedPilot = mat2cell(ReceivedPacket(1,:,:),1,NumSC,ones(1,NumPacket));
        PilotSeq = mat2cell(FixedPilotAll,1,NumPilot,ones(1,NumPacket));
        [EstChanLS,EstChanMMSE] = cellfun(wrapper,ReceivedPilot,PilotSeq,'UniformOutput',false);
        EstChanLS = cell2mat(squeeze(EstChanLS));
        EstChanMMSE = cell2mat(squeeze(EstChanMMSE));
        
        % Symbol detection
        SER_LS(snr,i) = getSymbolDetection(ReceivedPacket(2,idxSC,:),EstChanLS,Mod_Constellation,Label,DataLabel);
        SER_MMSE(snr,i) = getSymbolDetection(ReceivedPacket(2,idxSC,:),EstChanMMSE,Mod_Constellation,Label,DataLabel);
        
    end
    
end

SER_DL = mean(SER_DL,2).';
SER_LS = mean(SER_LS,2).';
SER_MMSE = mean(SER_MMSE,2).';


figure();
semilogy(Es_N0_dB,SER_DL,'r-o','LineWidth',2,'MarkerSize',10);hold on;
semilogy(Es_N0_dB,SER_LS,'b-o','LineWidth',2,'MarkerSize',10);hold on;
semilogy(Es_N0_dB,SER_MMSE,'k-o','LineWidth',2,'MarkerSize',10);hold off;
legend('Deep learning (DL)','Least square (LS)','Minimum mean square error (MMSE)');
xlabel('Es/N0 (dB)');
ylabel('Symbol error rate (SER)');

%%

function [EstChanLS,EstChanMMSE] = performChanEstimation(ReceivedData,PilotSeq,RHH,NoiseVar,NumPilot,NumSC,NumPath,idxSC)
% This function is to perform LS and MMSE channel estimations using pilot
% symbols, second-order statistics of the channel and noise variance [1].

% [1] O. Edfors, M. Sandell, J. -. van de Beek, S. K. Wilson and 
% P. Ola Borjesson, "OFDM channel estimation by singular value 
% decomposition," VTC, Atlanta, GA, USA, 1996, pp. 923-927 vol.2.


PilotSpacing = NumSC/NumPilot;

%%%%%%%%%%%%%%% LS estimation with interpolation %%%%%%%%%%%%%%%%%%%%%%%%%

H_LS = ReceivedData(1:PilotSpacing:NumSC)./PilotSeq;
H_LS_interp = interp1(1:PilotSpacing:NumSC,H_LS,1:NumSC,'linear','extrap');
H_LS_interp = H_LS_interp.';

%%%%%%%%%%%%%%%% MMSE estimation based on LS %%%%%%%%%%%%%%%%

[U,D,V] = svd(RHH);
d = diag(D);

InvertValue = zeros(NumSC,1);
if NumPilot >= NumPath
    
    InvertValue(1:NumPilot) = d(1:NumPilot)./(d(1:NumPilot)+NoiseVar);
    
else
    
    InvertValue(1:NumPath) = d(1:NumPath)./(d(1:NumPath)+NoiseVar);
    
end

H_MMSE = U*diag(InvertValue)*V'*H_LS_interp;

%%%%%%%%%%%%%%% Channel coefficient on the selected subcarrier %%%%%%%%%%%

EstChanLS = H_LS_interp(idxSC);
EstChanMMSE = H_MMSE(idxSC);

end

%% 

function SER = getSymbolDetection(ReceivedData,EstChan,Mod_Constellation,Label,DataLabel)
% This function is to calculate the symbol error rate from the equalized
% symbols based on hard desicion. 

EstSym = squeeze(ReceivedData)./EstChan;

% Hard decision
DecSym = sign(real(EstSym))+1j*sign(imag(EstSym));
DecLabel = zeros(size(DecSym));
for c = 1:length(Mod_Constellation)
    DecLabel(logical(DecSym == Mod_Constellation(c))) = Label(c);
end

SER = 1-sum(DecLabel == DataLabel)/length(EstSym);

end


 


3 仿真结果

4 参考文献

[1]姚如贵, 王圣尧, 秦倩楠,等. 一种基于深度学习的时变OFDM系统信号检测方法:. 

博主简介:擅长智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,相关matlab代码问题可私信交流。

部分理论引用网络文献,若有侵权联系博主删除。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

matlab科研助手

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值