%% 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
没有合适的资源?快使用搜索试试~ 我知道了~
【OFDM通信】基于深度学习的OFDM系统信号检测附matlab代码.zip
共16个文件
mat:8个
m:5个
fig:2个
1.该资源内容由用户上传,如若侵权请联系客服进行举报
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
2.虚拟产品一经售出概不退款(资源遇到问题,请及时私信上传者)
版权申诉
5星 · 超过95%的资源 1 下载量 141 浏览量
2023-04-20
09:50:14
上传
评论
收藏 434KB ZIP 举报
温馨提示
1.版本:matlab2014/2019a,内含运行结果,不会运行可私信 2.领域:智能优化算法、神经网络预测、信号处理、元胞自动机、图像处理、路径规划、无人机等多种领域的Matlab仿真,更多内容可点击博主头像 3.内容:标题所示,对于介绍可点击主页搜索博客 4.适合人群:本科,硕士等教研学习使用 5.博客介绍:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可si信
资源推荐
资源详情
资源评论
收起资源包目录
【OFDM通信】基于深度学习的OFDM系统信号检测附matlab代码.zip (16个子文件)
TrainedNetPilot64_CP0.mat 125KB
genTransmissionReceptionOFDM.m 1KB
SimParametersPilot64_CP0.mat 6KB
RHH.mat 48KB
CP.fig 698KB
SimParametersPilot64.mat 6KB
SavedChan.mat 3KB
TrainedNetPilot8.mat 126KB
1.png 35KB
TrainingdataGeneration.m 5KB
Pilot.fig 745KB
getFeatureAndLabel.m 918B
Testing.m 6KB
TrainedNetPilot64.mat 125KB
SimParametersPilot8.mat 5KB
TrainDNN.m 1KB
共 16 条
- 1
资源评论
- 2301_770014882023-11-07感谢资源主的分享,很值得参考学习,资源价值较高,支持!
Matlab科研辅导帮
- 粉丝: 3w+
- 资源: 7806
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- Delphi 12 控件之FlashAV FFMPEG VCL Player For Delphi v7.0 for D10-D11 Full Source.7z
- Delphi 12 控件之DevExpressVCLProducts-24.2.3.exe.zip
- Mysql配置文件优化内容 my.cnf
- 中国地级市CO2排放数据(2000-2023年).zip
- smart200光栅报警程序
- 企业信息部门2024年终工作总结与2025规划方案
- 串口AT命令发送工具,集成5G模组常用At命令
- 通过python实现归并排序示例代码.zip
- 复旦大学张奇:2023年大规模语言模型中的多语言对齐与知识分区研究
- 通过python实现一个堆排序示例代码.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功