Matlab:绘制简单能量的接收机工作特性曲线(Energy_detection_simulation_ok)

举报
一个处女座的程序猿 发表于 2021/03/28 00:48:04 2021/03/28
【摘要】 Matlab:绘制简单能量的接收机工作特性曲线(Energy_detection_simulation_ok)     目录 输出结果 实现代码           输出结果   实现代码 % This code is to plot receiver opera...

Matlab:绘制简单能量的接收机工作特性曲线(Energy_detection_simulation_ok)

 

 

目录

输出结果

实现代码


 

 

 

 

 

输出结果

 

实现代码

% This code is to plot receiver operating characteristic curve for simple energy
%绘制简单能量的接收机工作特性曲线
% detection, when the primary signal is real Gaussian signal and noise is
% addive white real Gaussian. Here, the threshold is available
% analytically.
% Code written by: Sanket Kalamkar, Indian Institute of Technology Kanpur,
% India.

%% 以下代码绘制在虚警概率一定时,检测概率和信噪比之间的关系曲线称为检测器的检测性能曲线
clc
close all
clear all
L = 1000; % The number of samples
snr = 0.01:0.01:10;
Pf = 10e-4; % Pf = Probability of False Alarm 虚警概率确定
%% Simulation to plot SNR vs.Probability of Detection (Pd)
for m = 1:length(snr) i = 0; thresh = (qfuncinv(Pf)./sqrt(L))+ 1; % Theoretical value of Threshold, refer, Sensing-Throughput Tradeoff for Cognitive Radio Networks, Y. C. Liang for kk = 1:5000 % Number of Monte Carlo Simulations(https://cn.mathworks.com/discovery/monte-carlo-simulation.html) n = randn(1,L); % AWGN noise with mean 0 and variance 1 s = sqrt(snr(m)).*randn(1,L); % Real valued Gaussina Primary User Signal y = s + n; % Received signal at SU(认知用户接收到的信号) energy = abs(y).^2; % Energy of received signal over N samples energy_fin =(1/L).*sum(energy); % Test Statistic for the energy detection if(energy_fin >= thresh) % Check whether the received energy is greater than threshold, if so, increment Pd (Probability of detection) counter by 1 i = i+1; end end Pd(m) = i/kk;
end
plot(10*log(snr), Pd,  'r')
xlabel('信噪比,单位db');
ylabel('检测概率');
title('能量感知检测性能曲线');
grid on
hold on
%% Theroretical expression of Probability of Detection; refer above reference.
thresh = (qfuncinv(Pf)./sqrt(L))+ 1;
%Pd_the = qfunc(((thresh - (snr + 1)).*sqrt(L))./(sqrt(2).*(snr + 1))); % 原来代码中的表达与论文中不一致
for k = 1:length(snr) Pd_the(k) = qfunc(((thresh - (snr(k) + 1)).*sqrt(L))./(sqrt(2).*snr(k) + 1)); % 与论文中的方程式保持一致
end
plot(10*log(snr), Pd_the, 'b')
legend('实际检测概率', '理论检测概率', 'Location', 'SouthEast');
hold on
grid on

 

 

文章来源: yunyaniu.blog.csdn.net,作者:一个处女座的程序猿,版权归原作者所有,如需转载,请联系作者。

原文链接:yunyaniu.blog.csdn.net/article/details/80343495

【版权声明】本文为华为云社区用户转载文章,如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱: cloudbbs@huaweicloud.com
  • 点赞
  • 收藏
  • 关注作者

评论(0

0/1000
抱歉,系统识别当前为高风险访问,暂不支持该操作

全部回复

上滑加载中

设置昵称

在此一键设置昵称,即可参与社区互动!

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。

*长度不超过10个汉字或20个英文字符,设置后3个月内不可修改。