基于MATLAB的CFAR检测仿真程序分享

基于MATLAB的CFAR检测仿真,得到平均CFAR检测。

基于MATLAB的CFAR检测仿真程序分享_第1张图片

 完整程序:

clc;
clear;
close all;
warning off;
addpath(genpath(pwd));

cfar = phased.CFARDetector('NumTrainingCells',200,'NumGuardCells',50,'Method','CA');


% Expected probability of False Alarm (no units)
pfa_expected = 1e-2;

% Setting parameters for CFAR Detector object
cfar.ThresholdFactor = 'Auto';
cfar.ProbabilityFalseAlarm = pfa_expected;

% Assume 10dB SNR ratio
npower = db2pow(-10);
% Total number of points
Total_points = 1e3;
%Number of trials done 
Num_of_Trials = 1;
% Total cells in window
Num_of_Cells = 251;
% Index of Cell Under test
Cut_Id = 126;

% To obtain the detection threshold
cfar.ThresholdOutputPort = true;


% Seed to generate random number
rs = RandStream('mt19937ar','Seed',2010);

%Modeling Received Signal
rsamp = randn(rs,Total_points,1)+1i*randn(rs,Total_points,1);
Rx_Signal = linspace(1,10,Total_points)';
Rx_sld = abs(sqrt(npower*Rx_Signal./2).*rsamp).^2;

% Applying CFAR funtion to get thresholds
[x_detected,th] = cfar(Rx_sld,1:length(Rx_sld));
plot(1:length(Rx_sld),Rx_sld,1:length(Rx_sld),th,find(x_detected),Rx_sld(x_detected),'o')
legend('Signal','Threshold','Detections','Location','northwest')
title('Cell Averaging CFAR Detection ')
xlabel('Time Index')
ylabel('Threshold')

你可能感兴趣的:(MATLAB代码(非电气),CFAR检测)