一、简介
1 内容简介
利用MATLAB GUI设计平台,设计多算法雷达一维恒虚警检测CFAR可视化界面,通过选择噪声类型、目标类型、算法类型,手动输入相关参数,可视化显示噪声波形与目标检测的回波-检测门限波形图。
2 原理简介
恒虚警检测技术(CFAR)是指雷达系统在保持虚警概率恒定条件下对接收机输出的信号与噪声作判别以确定目标信号是否存在的技术。
前提:由于接收机输出端中肯定存有噪声(包括大气噪声、人为噪声、内部噪声和杂波等),而信号一般是叠加在噪声上的。这就需要在接收机输出的噪声或信号加噪声条件下,采用检测技术判别是否有目标信号。
误差概率:任何形式的判决必然存在着两种误差概率:发现概率和虚警概率。当接收机输出端存在目标回波信号,而判决时判为有目标的概率为Pd,判为无目标的概率为1-Pad。当接收机输出端只有噪声时,而判为有目标的概率为Pfa。由于噪声是随机变量,其特征可用概率密度函数表示,因此信号加噪声也是一随机变量
具体过程:恒虚警检测器首先对输入的噪声进行处理后确定一个门限,将此门限与输入端信号相比,如输入端信号超过了此门限,则判为有目标,否则,判为无目标。
算法:①均值类CFRA:核心思想是通过对参考窗内采样数据取平均来估计背景功率。CA-CFAR(单元平均恒虚警)、GO-CFAR(最大选择恒虚警)、SO-CFAR(最小选择恒虚警)算法这三个是最经典的均值类CFAR算法。
②统计有序CFAR:核心思想:通过对参考窗内的数据由小到大排序选取其中第K个数值假设其为杂波背景噪声。OS-CFAR(有序统计恒虚警)为其经典算法。
3 实现功能
实现的功能有:
3.1 类型选择:
① 噪声类型:均匀背景噪声和杂波边缘背景噪声。均匀背景噪声为单一功率的噪声,在参数输入界面输入噪声功率2,噪声长度2,噪声方差即可(噪声功率1、噪声长度1被禁用);杂波边缘背景噪声为两种不同功率噪声的组合,需要分别输入噪声1和噪声2的功率与长度,方差两噪声共用。
②目标类型:单目标与多目标。选择单目标时只需输入目标1的信噪比与位置即可(其他目标被禁用);选择多目标时,需要分别输入目标1-4的信噪比与位置,其中当噪声类型为杂波边缘背景噪声时,还需分别输入靠近杂波边缘与杂波内目标的信噪比与位置,便于区别对比。
③算法类型:CA-CFAR、GO-CFAR、SO-CFAR、OS-CFAR,四种算法任选一种即可。
3.2 产生噪声&噪声波形图:完成噪声类型选择与噪声参数输入后,单击产生噪声按钮即可产生噪声波形图,在左下方进行显示。
3.3 参数输入:① 噪声功率1/2:噪声功率大小,单位db,变量名为db1、db2。
②噪声长度1/2:噪声的长度,其中噪声长度2为噪声总长(包括了噪声长度1),变量名为shape1、shape2。
③噪声方差:两段噪声共用的方差,变量名为varience。
④信噪比1/2/3/4/5/6:每个目标的信噪比,变量名为SNR1/2/3/4/5/6。
⑤目标位置1/2/3/4、杂波边缘位置,杂波内位置:各目标位置,需要小于最大噪声长度,其中杂波边缘位置应为两段噪声交界处,杂波内位置应在杂波内,变量名为des1/2/3/4/5/6。
⑥单元数目:总检测单元个数,变量名为N。
⑦保护单元数目:目标的功率可能泄露到相邻的单元中,所以和目标相邻的数个单元不作为背景杂波的估计,作为保护单元,变量名为pro_N。
⑧虚警概率:恒虚警检测保持的错误检测概率,变量名为PAD。
3.4 输出结果&回波-检测门限关系图:产生噪声,输入目标参数,选择算法后,单击输出结果按钮,即可在右侧得到回波-检测门限关系图。
3.5 左/右图导出:分别将噪声波形图与回波-检测门限关系图导出保存,可选的格式有jpg、png、bmp、eps。
4 操作实例
选取噪声类型为“杂波边缘背景噪声”,目标类型为多目标,算法类型选择CA-CFAR,参数输入为默认输入(噪声功率1/2:20db、30db;噪声长度1/2:100、200;噪声方差:200;信噪比1/2/3/4/5/6:15、12、8、5、5、5;目标位置1/2/3/4、杂波边缘位置、杂波内位置:30、40、50、60、95、120;单元个数:36;保护单元个数:2;虚警概率:0.001),得到结果如下图所示:从回波-检测门限图可以看出,该算法在低噪声环境中目标检测性能良好,实现恒虚警检测,但在杂波边缘与杂波内部检测性能显著下降。
5 算法与参数分析
算法分析:
CA-CFAR:优点:损失率最少的一种算法;
缺点:多目标遮掩,杂波边缘性能也欠佳;
GO-CFAR:优点:杂波边缘区域虚警概率降低
缺点:多目标遮掩
SO-CFAR: 优点:多目标效果有改进;
缺点:杂波边缘区域虚警概率提升;
OS-CFAR:优点:多目标检测性能很好;
缺点:杂波边缘区域虚警概率提高;
参数分析:
检测单元数:在相同信噪比下,检测单元数越多的CFAR对应的检测概率越高,但同时计算量加大。
虚警概率:在相同检测单元数目下,虚警概率的越高CFAR对应的检测概率越高,但虚警数也增多。
信噪比:当信噪比不断增加,检测概率也不断增加。
保护单元数:保护单元过大或过小都会使检测概率降低,应不同实验选取适中的保护单元数。
二、源代码
function varargout = cfar(varargin)
%CFAR MATLAB code file for cfar.fig
% CFAR, by itself, creates a new CFAR or raises the existing
% singleton*.
%
% H = CFAR returns the handle to a new CFAR or the handle to
% the existing singleton*.
%
% CFAR('Property','Value',...) creates a new CFAR using the
% given property value pairs. Unrecognized properties are passed via
% varargin to cfar_OpeningFcn. This calling syntax produces a
% warning when there is an existing singleton*.
%
% CFAR('CALLBACK') and CFAR('CALLBACK',hObject,...) call the
% local function named CALLBACK in CFAR.M with the given input
% arguments.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help cfar
% Last Modified by GUIDE v2.5 12-May-2020 18:48:44
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @cfar_OpeningFcn, ...
'gui_OutputFcn', @cfar_OutputFcn, ...
'gui_LayoutFcn', [], ...
'gui_Callback', []);
if nargin && ischar(varargin{
1})
gui_State.gui_Callback = str2func(varargin{
1});
end
if nargout
[varargout{
1:nargout}] = gui_mainfcn(gui_State, varargin{
:});
else
gui_mainfcn(gui_State, varargin{
:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before cfar is made visible.
function cfar_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin unrecognized PropertyName/PropertyValue pairs from the
% command line (see VARARGIN)
% Choose default command line output for cfar
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes cfar wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = cfar_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{
1} = handles.output;
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global noise_p;
global xc;
axes(handles.axes5);
if get(handles.radiobutton4,'value')
shape1=get(handles.edit9,'string');
shape1=str2double(shape1);
shape2=get(handles.edit10,'string');
shape2=str2double(shape2);
db1=get(handles.edit1,'string');
db1=str2double(db1);
db2=get(handles.edit8,'string');
db2=str2double(db2);
shape=[shape1,shape2];
variance=get(handles.edit2,'string');
variance=str2double(variance);
noise_db=[db1,db2];
noise_p=10.^(noise_db./10);
show_out=1;
[ xc ] = env_edge(variance, shape, noise_db,show_out);
end
if get(handles.radiobutton3,'value')
shape1=get(handles.edit10,'string');
shape1=str2double(shape1);
variance=get(handles.edit2,'string');
variance=str2double(variance);
db1=get(handles.edit1,'string');
db1=str2double(db1);
noise_p=10.^(db1./10);
show_out=1;
[ xc ] = env_uniform(variance, shape1, db1,show_out);
end
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
global noise_p;
global xc;
if get(handles.radiobutton3,'value')&&get(handles.radiobutton1,'value')
SNR1=get(handles.edit4,'string');
SNR1=str2double(SNR1);
signal1_p=10.^(SNR1./10).*noise_p;
des1=get(handles.edit15,'string');
des1=str2double(des1);
xc(1,des1)=signal1_p;
N=get(handles.edit13,'string');
N=str2double(N);
pro_N=get(handles.edit7,'string');
pro_N=str2double(pro_N);
PAD=get(handles.edit14,'string');
PAD=str2double(PAD);
k=2.*N./4;
if get(handles.radiobutton5,'value')&&get(handles.radiobutton1,'value')
[ index, XT ] = cfar_ac( xc, N, pro_N, PAD);
end
if get(handles.radiobutton6,'value')&&get(handles.radiobutton1,'value')
[ index, XT ] = cfar_go( xc, N, pro_N, PAD);
end
if get(handles.radiobutton7,'value')&&get(handles.radiobutton1,'value')
[ index, XT ] = cfar_os( abs(xc), N, k, pro_N, PAD);
end
if get(handles.radiobutton8,'value')&&get(handles.radiobutton1,'value')
[ index, XT ] = cfar_so( xc, N, pro_N, PAD);
end
end
if get(handles.radiobutton4,'value')&&get(handles.radiobutton1,'value')
SNR1=get(handles.edit4,'string');
SNR1=str2double(SNR1);
signal1_p=10.^(SNR1./10).*noise_p(1,end);
des1=get(handles.edit15,'string');
des1=str2double(des1);
xc(1,des1)=signal1_p;
N=get(handles.edit13,'string');
N=str2double(N);
pro_N=get(handles.edit7,'string');
pro_N=str2double(pro_N);
PAD=get(handles.edit14,'string');
PAD=str2double(PAD);
k=2.*N./4;
if get(handles.radiobutton5,'value')&&get(handles.radiobutton1,'value')
[ index, XT ] = cfar_ac( xc, N, pro_N, PAD);
end
if get(handles.radiobutton6,'value')&&get(handles.radiobutton1,'value')
[ index, XT ] = cfar_go( xc, N, pro_N, PAD);
end
if get(handles.radiobutton7,'value')&&get(handles.radiobutton1,'value')
[ index, XT ] = cfar_os( abs(xc), N, k, pro_N, PAD);
end
if get(handles.radiobutton8,'value')&&get(handles.radiobutton1,'value')
[ index, XT ] = cfar_so( xc, N, pro_N, PAD);
end
end
if get(handles.radiobutton3,'value')&&get(handles.radiobutton2,'value')
SNR1=get(handles.edit4,'string');
SNR1=str2double(SNR1);
SNR2=get(handles.edit5,'string');
SNR2=str2double(SNR2);
SNR3=get(handles.edit11,'string');
SNR3=str2double(SNR3);
SNR4=get(handles.edit12,'string');
SNR4=str2double(SNR4);
signal1_p=10.^(SNR1./10).*noise_p;
signal2_p=10.^(SNR2./10).*noise_p;
signal3_p=10.^(SNR3./10).*noise_p;
signal4_p=10.^(SNR4./10).*noise_p;
des1=get(handles.edit15,'string');
des1=str2double(des1);
des2=get(handles.edit16,'string');
des2=str2double(des2);
des3=get(handles.edit17,'string');
des3=str2double(des3);
des4=get(handles.edit18,'string');
des4=str2double(des4);
xc(1,des1)=signal1_p;
xc(1,des2)=signal2_p;
xc(1,des3)=signal3_p;
xc(1,des4)=signal4_p;
N=get(handles.edit13,'string');
N=str2double(N);
pro_N=get(handles.edit7,'string');
pro_N=str2double(pro_N);
PAD=get(handles.edit14,'string');
PAD=str2double(PAD);
k=2.*N./4;
if get(handles.radiobutton5,'value')&&get(handles.radiobutton2,'value')
[ index, XT ] = cfar_ac( xc, N, pro_N, PAD);
end
if get(handles.radiobutton6,'value')&&get(handles.radiobutton2,'value')
[ index, XT ] = cfar_go( xc, N, pro_N, PAD);
end
if get(handles.radiobutton7,'value')&&get(handles.radiobutton2,'value')
[ index, XT ] = cfar_os( abs(xc), N, k, pro_N, PAD);
end
if get(handles.radiobutton8,'value')&&get(handles.radiobutton2,'value')
[ index, XT ] = cfar_so( xc, N, pro_N, PAD);
end
end
if get(handles.radiobutton4,'value')&&get(handles.radiobutton2,'value')
SNR1=get(handles.edit4,'string');
SNR1=str2double(SNR1);
SNR2=get(handles.edit5,'string');
SNR2=str2double(SNR2);
SNR3=get(handles.edit11,'string');
SNR3=str2double(SNR3);
SNR4=get(handles.edit12,'string');
SNR4=str2double(SNR4);
SNR5=get(handles.edit19,'string');
SNR5=str2double(SNR5);
SNR6=get(handles.edit20,'string');
SNR6=str2double(SNR6);
signal1_p=10.^(SNR1./10).*noise_p(1,end);
signal2_p=10.^(SNR2./10).*noise_p(1,end);
signal3_p=10.^(SNR3./10).*noise_p(1,end);
signal4_p=10.^(SNR4./10).*noise_p(1,end);
signal5_p=10.^(SNR4./10).*noise_p(1,end);
signal6_p=10.^(SNR4./10).*noise_p(1,end);
des1=get(handles.edit15,'string');
des1=str2double(des1);
des2=get(handles.edit16,'string');
des2=str2double(des2);
des3=get(handles.edit17,'string');
des3=str2double(des3);
des4=get(handles.edit18,'string');
des4=str2double(des4);
des5=get(handles.edit21,'string');
des5=str2double(des5);
des6=get(handles.edit22,'string');
des6=str2double(des6);
xc(1,des1)=signal1_p;
xc(1,des2)=signal2_p;
xc(1,des3)=signal3_p;
xc(1,des4)=signal4_p;
xc(1,des5)=signal5_p;
xc(1,des6)=signal6_p;
N=get(handles.edit13,'string');
N=str2double(N);
pro_N=get(handles.edit7,'string');
pro_N=str2double(pro_N);
PAD=get(handles.edit14,'string');
PAD=str2double(PAD);
k=2.*N./4;
if get(handles.radiobutton5,'value')&&get(handles.radiobutton2,'value')
[ index, XT ] = cfar_ac( xc, N, pro_N, PAD);
end
if get(handles.radiobutton6,'value')&&get(handles.radiobutton2,'value')
[ index, XT ] = cfar_go( xc, N, pro_N, PAD);
end
if get(handles.radiobutton7,'value')&&get(handles.radiobutton2,'value')
[ index, XT ] = cfar_os( abs(xc), N, k, pro_N, PAD);
end
if get(handles.radiobutton8,'value')&&get(handles.radiobutton2,'value')
[ index, XT ] = cfar_so( xc, N, pro_N, PAD);
end
end
axes(handles.axes2);
cla reset
if get(handles.radiobutton1,'value')
plot(10.*log(abs(xc))./log(10)),hold on;
plot(des1,10.*log(abs(xc(1,des1)))./log(10),'r*', 'LineWidth',10),hold on;
plot(index,10.*log(abs(XT))./log(10),'g');
legend('回波','目标','检测门限')
end
if get(handles.radiobutton2,'value')&&get(handles.radiobutton3,'value')
plot(10.*log(abs(xc))./log(10)),hold on;
plot(des1,10.*log(abs(xc(1,des1)))./log(10),'r*', 'LineWidth',10),hold on;
plot(des2,10.*log(abs(xc(1,des2)))./log(10),'r*', 'LineWidth',10),hold on;
plot(des3,10.*log(abs(xc(1,des3)))./log(10),'r*', 'LineWidth',10),hold on;
plot(des4,10.*log(abs(xc(1,des4)))./log(10),'r*', 'LineWidth',10),hold on;
plot(index,10.*log(abs(XT))./log(10),'g');
legend('回波','目标','目标','目标','目标','检测门限')
end
if get(handles.radiobutton2,'value')&&get(handles.radiobutton4,'value')
plot(10.*log(abs(xc))./log(10)),hold on;
plot(des1,10.*log(abs(xc(1,des1)))./log(10),'r*', 'LineWidth',10),hold on;
plot(des2,10.*log(abs(xc(1,des2)))./log(10),'r*', 'LineWidth',10),hold on;
plot(des3,10.*log(abs(xc(1,des3)))./log(10),'r*', 'LineWidth',10),hold on;
plot(des4,10.*log(abs(xc(1,des4)))./log(10),'r*', 'LineWidth',10),hold on;
plot(des5,10.*log(abs(xc(1,des5)))./log(10),'y*', 'LineWidth',10),hold on;
plot(des6,10.*log(abs(xc(1,des6)))./log(10),'b*', 'LineWidth',10),hold on;
plot(index,10.*log(abs(XT))./log(10),'g');
legend('回波','目标','目标','目标','目标','杂波边缘目标','杂波内目标','检测门限')
end
function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double
三、运行结果
四、备注
版本:2014
完整代码或者代写添加QQ 1564658423
转载:https://blog.csdn.net/TIQCmatlab/article/details/116356415