Files
Algorithm/OS_CFAR.m
Nicole 34c17ce82a CFAR
CFAR方法实现
2020-09-06 15:20:13 +08:00

72 lines
1.9 KiB
Matlab
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
%-OS-CFAR检测器均匀背景与杂波干扰目标背景下性能仿真-
clc;
clear all;
N=32;
r=3; %CMLD_CFAR检测器筛除掉r个较大的参考样本单元
R=N-r; %参考单元长度
n=N/2; %半滑窗长度
k=3*N/4;
T=16.2933; %标称系数
Pfa=1e-6; %虚警概率
syms T0
g=Pfa-k*nchoosek(R,k)*gamma(R-k+1+T0)*gamma(k)/gamma(R+T0+1);
x=solve(g);
T0=double(x);
M=1e4; %蒙特卡洛仿真次数
SNR_dB=5:1:35; %信噪比
SNR=10.^(SNR_dB./10);
Simul_len=length(SNR); %仿真长度
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%OS-CFAR ideal%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i=1:Simul_len
Pd(i)=OS_Pd_Fun(N,k,T,SNR(i));
end
plot(SNR_dB,Pd,'b');
hold on
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%OS-CFAR simulation%%%%%%%%%%%%%%%%%%%%%%%%
for i=1:Simul_len
count=0;
for j=1:M
lambda=1; %产生噪声长度为N
u=rand(1,N);
exp_noise=log(u)*(-lambda);
lambda=SNR(i); %产生待检测单元
u=rand(1,2);
CUT=log(u(1))*(-lambda);
exp_noise(N)=log(u(2))*(-lambda);
exp_noise=sort(exp_noise);
if(CUT>T*exp_noise(k))
count=count+1;
end
end
Pd_sim(i)=count/M;
end
plot(SNR_dB,Pd_sim,'-*r');
hold on
%%%%%%%%%%%%%%%CMLD_CFAR检测器筛除掉r个较大的参考样本单%%%%%%%%%%%%%%%%%%
for i=1:Simul_len
count=0;
for j=1:M
lambda=1; %产生噪声长度为N-1
u=rand(1,N-1);
exp_noise(1:N-1)=log(u)*(-lambda);
lambda=SNR(i); %产生待检测单元及一个干扰目标
u=rand(1,2);
CUT=log(u(1))*(-lambda);
exp_noise(N)=log(u(2))*(-lambda);
exp_noise=sort(exp_noise);
exp_noise1(1:N-r)=exp_noise(1:N-r);
if(CUT>T0*exp_noise1(k))
count=count+1;
end
end
Pd_sim_1(i)=count/M;
end
plot(SNR_dB,Pd_sim_1,'--g');
hold on
title('OS-CFAR 检测概率曲线,N=32,Pf=1e-6');
xlabel('信噪比(dB)');ylabel('检测概率');
legend('OS-ideal','OS-simulation','OS-1interference');