CFAR方法实现
This commit is contained in:
Nicole
2020-09-06 15:20:13 +08:00
parent c70b7d34d6
commit 34c17ce82a
4 changed files with 243 additions and 0 deletions

81
GO_CFAR.m Normal file
View File

@@ -0,0 +1,81 @@
% GO-CFAR仿-
clc;clear all;close all;
N=36; %
n=N/2; %
M=1e4; %仿
SNR_dB=5:1:35; %
SNR=10.^(SNR_dB./10);
Simul_len=length(SNR); %仿
T=0.8551;
Pd_GO1=0;
for i=1:length(SNR)
count=0;
for j=1:M
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
lambda=1;
u=rand(1,N-1);
exp_noise=log(u)*(-lambda);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
lambda=SNR(i)+1;
u=rand(1,2);
exp_target=log(u(1))*(-lambda);
exp_noise(N)=log(u(2))*(-lambda);
cfar_k=exp_target/max(sum(exp_noise(1:N/2)),sum(exp_noise((N/2+1):N)));
if (cfar_k>T)
count=count+1;
end
end
Pd_GO1(i)=count/M;
end
figure;
plot(SNR_dB,Pd_GO1,'b--','LineWidth',1.5);
hold on
Pd_GO2=0;
for i=1:length(SNR)
count=0;
for j=1:M
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
lambda=1;
u=rand(1,N-2);
exp_noise=log(u)*(-lambda);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
lambda=SNR(i)+1;
u=rand(1,3);
exp_target=log(u(1))*(-lambda);
exp_noise(N)=log(u(2))*(-lambda);
exp_noise(N-1)=log(u(3))*(-lambda);
cfar_k=exp_target/max(sum(exp_noise(1:N/2)),sum(exp_noise((N/2+1):N)));
if (cfar_k>T)
count=count+1;
end
end
Pd_GO2(i)=count/M;
end
plot(SNR_dB,Pd_GO2,'r--*','LineWidth',1.5);
hold on
Pd_GO3=0;
for i=1:length(SNR)
count=0;
for j=1:M
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
lambda=1;
u=rand(1,N-2);
exp_noise=log(u)*(-lambda);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
lambda=SNR(i)+1;
u=rand(1,3);
exp_target=log(u(1))*(-lambda);
exp_noise(N)=log(u(2))*(-lambda);
exp_noise(N-1)=log(u(3))*(-lambda);
exp_noise=[exp_noise(1:n-1) exp_noise(N-1) exp_noise(n:N-1) exp_noise(N)];
cfar_k=exp_target/max(sum(exp_noise(1:N/2)),sum(exp_noise((N/2+1):N)));
if (cfar_k>T)
count=count+1;
end
end
Pd_GO3(i)=count/M;
end
plot(SNR_dB,Pd_GO3,'g-.','LineWidth',1.5);
xlabel('(dB)');ylabel('');
title('GO-CAFRN=36,Pf=1e-6');
legend('r=(0,1)','r=(0,2)','r=(1,1)');

72
OS_CFAR.m Normal file
View File

@@ -0,0 +1,72 @@
%-OS-CFAR仿-
clc;
clear all;
N=32;
r=3; %CMLD_CFARr
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_CFARr%%%%%%%%%%%%%%%%%%
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');

4
OS_Pd_Fun.m Normal file
View File

@@ -0,0 +1,4 @@
function [Pd]=OS_Pd_Fun(R,k,T,lammbd)
%OS-CFAR
%Rkk,lammbd:,T
Pd=k*nchoosek(R,k)*gamma(R-k+1+T/(1+lammbd))*gamma(k)/gamma(R+T/(1+lammbd)+1);

86
SO_CFAR.m Normal file
View File

@@ -0,0 +1,86 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% SO-CAFRN=32,Pf=1e-6
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clc;clear all;close all;
N=36; %
n=N/2; %
M=1e4; %仿
SNR_dB=5:1:35; %
SNR=10.^(SNR_dB./10);
Simul_len=length(SNR); %仿
T=1.2379;
Pd_SO1=0;
%%%%%%%%%%%%%%%%%%%%%%%%%%%1%%%%%%%%%%%%%%%%%%%
for i=1:length(SNR)
count=0;
for j=1:M
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
lambda=1;
u=rand(1,N-1);
exp_noise=log(u)*(-lambda);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
lambda=SNR(i)+1;
u=rand(1,2);
exp_target=log(u(1))*(-lambda);
exp_noise(N)=log(u(2))*(-lambda);
cfar_k=exp_target/min(sum(exp_noise(1:N/2)),sum(exp_noise((N/2+1):N)));
if (cfar_k>T)
count=count+1;
end
end
Pd_SO1(i)=count/M;
end
figure;
plot(SNR_dB,Pd_SO1,'b--','LineWidth',1.5);
hold on
Pd_SO2=0;
%%%%%%%%%%%%%%%%%%%%%%%%2%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
for i=1:length(SNR)
count=0;
for j=1:M
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
lambda=1;
u=rand(1,N-2);
exp_noise=log(u)*(-lambda);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
lambda=SNR(i)+1;
u=rand(1,3);
exp_target=log(u(1))*(-lambda);
exp_noise(N)=log(u(2))*(-lambda);
exp_noise(N-1)=log(u(3))*(-lambda);
cfar_k=exp_target/min(sum(exp_noise(1:N/2)),sum(exp_noise((N/2+1):N)));
if (cfar_k>T)
count=count+1;
end
end
Pd_SO2(i)=count/M;
end
plot(SNR_dB,Pd_SO2,'r--*','LineWidth',1.5);
hold on
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%1%%%%%%%%%%%%%%
Pd_SO3=0;
for i=1:length(SNR)
count=0;
for j=1:M
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
lambda=1;
u=rand(1,N-2);
exp_noise=log(u)*(-lambda);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
lambda=SNR(i)+1;
u=rand(1,3);
exp_target=log(u(1))*(-lambda);
exp_noise(N)=log(u(2))*(-lambda);
exp_noise(N-1)=log(u(3))*(-lambda);
exp_noise=[exp_noise(1:n-1) exp_noise(N-1) exp_noise(n:N-1) exp_noise(N)];
cfar_k=exp_target/min(sum(exp_noise(1:N/2)),sum(exp_noise((N/2+1):N)));
if (cfar_k>T)
count=count+1;
end
end
Pd_SO3(i)=count/M;
end
plot(SNR_dB,Pd_SO3,'g-.','LineWidth',1.5);
title('CA-CAFRN=36,Pf=1e-6');
legend('r=(0,1)','r=(0,2)','r=(1,1)');
xlabel('(dB)');ylabel('');