基于Matlab计算经典CFAR阈值

简介: 基于Matlab计算经典CFAR阈值

✅作者简介:热爱科研的Matlab仿真开发者,修心和技术同步精进,matlab项目合作可私信。

🍎个人主页:Matlab科研工作室

🍊个人信条:格物致知。

更多Matlab仿真内容点击👇

智能优化算法  神经网络预测雷达通信 无线传感器

信号处理图像处理路径规划元胞自动机无人机 电力系统

⛄ 内容介绍

基于Matlab计算经典CFAR阈值

⛄ 完整代码

function T = calcCFARthreshold(nTest, nRef, thePFA)

% calculates classical radar CFAR threshold for 0-mean AWGN

% classical Neyman-Pearson detection threshold for radar detection

% under additive Gaussian white noise criterion and specifid false alarm

% probability.

% the threshold T is calculated such that under the noise-only condition

% 计算0均值AWGN的经典雷达CFAR阈值

% 雷达检测的经典Neyman-Pearson检测阈值

% 在加性高斯白噪声准则和特定的虚警概率下

% 仅在噪声条件下计算阈值T

% prob(Ptest > T * Pref) <= pfa                        Eq(1)公式1

%

% where Ptest is the sum of normed-squares of the nTest cells

%       Pref  is the sum of normed-squares of the nRef cells

%       pfa is the required maximum type-I (aka false alarm prob) error

%其中:Ptest是nTest单元的标准平方和,Pref是nRef单元的标准平方和,pfa是所需的最大类型-I(又名虚警概率)误差

%

% inputs: nTest  - the number of noise-only test cells

%         nRef   - the number of noise-only reference cells

%         thePfA - maximum probability such that

%                  prob(Ptest/Pref > T) <= pfa         Eq(2)

%                  This is equivalent to Eq(1)

%inputs:nTest  - 仅噪声测试单元的数量

%        nRef  - 仅噪声参考单元的数量

%        thePfA  - 这样的最大概率prob(Ptest / Pref> T)<= pfa Eq(2)相当于方程(1)

% demo:  calcCFARthreshold;  % no inputs

%demo: 计算0均值AWGN的经典雷达CFAR阈值;%无输入

% the classical CFAR processor compares the total power in nTest cells

% to the power in nRef cells. The threshold T is selected so that the

% ratio of Eq(2) is satisfied. it is assumed that the both sets' cells

% contain only thermal (AWGN) noise. If this ratio exceeds T, it assumed a

% radar target exists. The probability that only noise exceeds T is given

% by the threshold T (usually on the order of 10^-4 to 10^-7).

%经典CFAR处理器将nTest单元中的总功率与nRef单元中的功率进行比较。

%选择阈值T使得满足Eq(2)(公式2)的比率。

%假设两组'单元仅包含热(AWGN)噪声。

%如果该比率超过T,则假定存在雷达目标。

%仅噪声超过T的概率由阈值T给出(通常在10 ^ -4到10 ^ -7的数量级)。

% michaelB brost. as usual, fully sharable under GPLv3

% michaelB brost. 像往常一样,在GPLv3下完全可以共享


% demo

if(nargin == 0),%nargin是用来判断输入变量个数的函数:如果输入变量的数目为0

   nTest = 10; %仅噪声测试单元个数

   nRef  = 25; %仅噪声参考单元的数量

   thePFA = 1e-4;%方程2:“prob(Ptest/Pref > T) <= pfa”的最大概率,方程2等效与方程1“prob(Ptest > T * Pref) <= pfa”

   T = calcCFARthreshold(nTest, nRef, thePFA);

   doTest(nTest, nRef, thePFA, T);

   clear('T');

   return;

end


% requires the statistics toolbox需要统计工具箱

T = finv(1 - thePFA, nTest, nRef) * nTest / nRef;


return


function doTest(nTest, nRef, thePfa, T)

% simple test of threshold calc阈值计算的简单测试


nPt   = min(1e5, ceil(50/thePfa));

nIter = 15;

nHit  = zeros(nIter, 1);


wHnd = waitbar(0, '');

for k1=1:nIter

   % test set noise power测试设置噪声功率

   testPower = sum(randn(nPt, nTest).^2, 2);


   % reference set noise power参考设定噪声功率

   refPower = sum(randn(nPt, nRef).^2, 2);

   

   % test

   index = find(testPower >= (T .* refPower));

   % >(大于),>=(大于等于),<(小于),<=(小于等于), ==(等于),~=(不等于)

   % count up contacts 计数

   nHit(k1) = length(index);

   

   waitbar(k1/nIter, wHnd, sprintf('PFA simulation iteration %d of %d', k1, nIter));

 

end


close(wHnd);


pHit = nHit / nPt;


figure;


stem(pHit);

ylabel('P_F_A');

xlabel('runs');


pfaAvg = mean(pHit);

pfaStd = sqrt(var(pHit));

title(sprintf(...

   'calculated average pfa: %5.3e, 1-sigma: %5.3e (design: %5.2e)\n', ...

   pfaAvg, pfaStd, thePfa));


hold on;

lHnd = line([1, nIter], [thePfa, thePfa]);

set(lHnd, 'color', 'k');


lHnd = line([1, nIter], [pfaAvg, pfaAvg]);

set(lHnd, 'color', 'b');


lHnd = line([1, nIter], [thePfa, thePfa] - pfaStd);

set(lHnd, 'color', 'r');


lHnd = line([1, nIter], [thePfa, thePfa] + pfaStd);

set(lHnd, 'color', 'r');


legend('simulated PFA', 'specified PFA', 'mean PFA', '1 \sigma limits', ...

'location', 'south');


set(gca, 'xlim', [0, nIter+1]);

⛄ 运行结果

⛄ 参考文献


⛄ Matlab代码关注

❤️部分理论引用网络文献,若有侵权联系博主删除
❤️ 关注我领取海量matlab电子书和数学建模资料


相关文章
|
11月前
|
边缘计算 资源调度 监控
无人机边缘计算中的计算卸载——Stackelberg博弈方法研究(Matlab代码实现)
无人机边缘计算中的计算卸载——Stackelberg博弈方法研究(Matlab代码实现)
533 3
|
11月前
|
Python
使用毕奥-萨伐尔定律计算圆形电流环的磁场,通过毕奥-萨伐尔定律,计算了圆形电流环的磁场(Matlab代码实现)
使用毕奥-萨伐尔定律计算圆形电流环的磁场,通过毕奥-萨伐尔定律,计算了圆形电流环的磁场(Matlab代码实现)
312 2
|
12月前
|
数据采集 数据可视化 前端开发
基于ARIMA电价预测,并计算置信区间研究(Matlab代码实现)
基于ARIMA电价预测,并计算置信区间研究(Matlab代码实现)
328 5
|
11月前
|
算法 机器人
基于SOA海鸥优化算法的PID控制器最优控制参数计算matlab仿真
本课题研究基于海鸥优化算法(SOA)优化PID控制器参数的方法,通过MATLAB仿真对比传统PID控制效果。利用SOA算法优化PID的kp、ki、kd参数,以积分绝对误差(IAE)为适应度函数,提升系统响应速度与稳定性。仿真结果表明,SOA优化的PID控制器在阶跃响应和误差控制方面均优于传统方法,具有更快的收敛速度和更强的全局寻优能力,适用于复杂系统的参数整定。
|
11月前
|
数据采集 算法 前端开发
MATLAB|基于3D FDTD的微带线馈矩形天线分析[用于模拟超宽带脉冲通过线馈矩形天线的传播,以计算微带结构的回波损耗参数]
MATLAB|基于3D FDTD的微带线馈矩形天线分析[用于模拟超宽带脉冲通过线馈矩形天线的传播,以计算微带结构的回波损耗参数]
419 2
|
11月前
|
canal 算法 vr&ar
【图像处理】基于电磁学优化算法的多阈值分割算法研究(Matlab代码实现)
【图像处理】基于电磁学优化算法的多阈值分割算法研究(Matlab代码实现)
277 1
|
11月前
|
算法
【电力系统潮流】5节点系统潮流计算-牛拉法和PQ分解法(Matlab代代码实现)
【电力系统潮流】5节点系统潮流计算-牛拉法和PQ分解法(Matlab代代码实现)
938 3
|
11月前
|
Serverless Python
【三变量联合分布函数copula】利用AIC BIC确定单变量最优拟合函数、利用AIC确定三变量联合最优copula函数、计算联合概率(Matlab代码实现)
【三变量联合分布函数copula】利用AIC BIC确定单变量最优拟合函数、利用AIC确定三变量联合最优copula函数、计算联合概率(Matlab代码实现)
652 4
|
11月前
|
存储 编解码 并行计算
【快速傅里叶变换FFT、窗函数法、希尔伯特-黄变换、小波变换】电力系统同步相量计算研究(Matlab代码实现)
【快速傅里叶变换FFT、窗函数法、希尔伯特-黄变换、小波变换】电力系统同步相量计算研究(Matlab代码实现)
336 6
|
11月前
|
传感器 算法 数据可视化
MATLAB来计算和仿真无人机飞行过程
使用MATLAB来计算和仿真无人机飞行过程中的运动参数是一个极其常见且强大的方法。这通常被称为无人机建模与仿真,是无人机飞控算法开发中不可或缺的一环。
561 1

热门文章

最新文章