当前位置:   article > 正文

雷达目标检测之恒虚警检测(CA/SOCA/OS/GOCA-CFAR)【附MATLAB代码】

goca-cfar

文章来源:微信公众号:EW Frontier

MATLAB主代码:

  1. clear; close all; clc;
  2. % 生成一个例子,然后用以下算法处理
  3. % CA CFAR, OS CFAR, SOCA CFAR, GOCA CFAR, S-CFAR, Log CFAR
  4. % 位置在50和55处有目标,50处信噪比10dB,55处信噪比15dB
  5. % 前100单元噪声功率20dB,后100单元噪声功率30dB
  6. num_cell = 200;
  7. Pfa = 10^(-5);
  8. signal1 = generateDataGaussianWhite(100, [50, 55], [35, 40], 20);
  9. signal2 = generateDataGaussianWhite(100, [], [], 30);
  10. signal = [signal1, signal2];
  11. plot(1:num_cell, pow2db(signal), 'k-', 'linewidth', 0.5);
  12. hold on;
  13. % CA CFAR处理
  14. [position, threshold, start_cell, stop_cell] = cacfar(signal, Pfa, 10, 2);
  15. plot(start_cell:stop_cell, pow2db(threshold), 'linewidth', 1);
  16. % OS CFAR处理
  17. [position, threshold, start_cell, stop_cell] = oscfar(signal, Pfa, 10, 2, 15);
  18. plot(start_cell:stop_cell, pow2db(threshold), 'linewidth', 1);
  19. % SOCA CFAR处理
  20. [position, threshold, start_cell, stop_cell] = socacfar(signal, Pfa, 10, 2);
  21. plot(start_cell:stop_cell, pow2db(threshold), 'linewidth', 1);
  22. % GOCA CFAR处理
  23. [position, threshold, start_cell, stop_cell] = gocacfar(signal, Pfa, 10, 2);
  24. plot(start_cell:stop_cell, pow2db(threshold), 'linewidth', 1);
  25. grid on;
  26. legend('信号', 'CA CFAR阈值', 'OS CFAR阈值', 'SOCA CFAR阈值', 'GOCA CFAR阈值');

CA-CFAR

  1. function [position, threshold, start_cell, stop_cell] = cacfar(signal, Pfa, ref_num, guard_num)
  2. % ======>INPUT:
  3. % signal: Data of signal(include signal and noise).[DATATYPE: row vector]
  4. % Pfa: Probability of false alarm.[DATATYPE: scalar]
  5. % ref_num: Number of reference cell.[DATATYPE: scalar]
  6. % guard_num: Number of guard cell.[DATATYPE: scalar]
  7. % ======>OUTPUT:
  8. % position: positions of target.[DATATYPE: row vector]
  9. % threshold: CFAR threshold of input signal.[DATATYPE: row vector]
  10. position = [];
  11. left_num = guard_num + ref_num;
  12. start_cell = left_num + 1;
  13. stop_cell = length(signal) - left_num;
  14. N = 2*ref_num;
  15. alpha = N * (Pfa ^ (-1/N) - 1);
  16. threshold = zeros(1, stop_cell - start_cell + 1);
  17. for ii = start_cell : stop_cell
  18. tmp_data = [signal(ii-left_num : ii-guard_num-1), ...
  19. signal(ii+guard_num+1 : ii+left_num)];
  20. tmp = mean(tmp_data) * alpha;
  21. % threshold(ii - left_num)
  22. % tmp
  23. threshold(ii - left_num) = tmp;
  24. if tmp < signal(ii)
  25. position = [position, ii];
  26. end
  27. end
  28. return

OS-CFAR

  1. function [position, threshold, start_cell, stop_cell] = oscfar(signal, Pfa, ref_num, guard_num, k)
  2. % ======>INPUT:
  3. % signal: Data of signal(include signal and noise).[DATATYPE: row vector]
  4. % Pfa: Probability of false alarm.[DATATYPE: scalar]
  5. % ref_num: Number of reference cell.[DATATYPE: scalar]
  6. % guard_num: Number of guard cell.[DATATYPE: scalar]
  7. % k: # k sorted statistical value.[DATATYPE: scalar]
  8. % ======>OUTPUT:
  9. % position: positions of target.[DATATYPE: row vector]
  10. % threshold: CFAR threshold of input signal.[DATATYPE: row vector]
  11. position = [];
  12. left_num = guard_num + ref_num;
  13. start_cell = left_num + 1;
  14. stop_cell = length(signal) - left_num;
  15. N = 2*ref_num;
  16. alpha = get_alpha(Pfa, N, k);
  17. threshold = zeros(1, stop_cell - start_cell + 1);
  18. for ii = start_cell : stop_cell
  19. tmp_data = [signal(ii-left_num : ii-guard_num-1), ...
  20. signal(ii+guard_num+1 : ii+left_num)];
  21. sorted_data = sort(tmp_data);
  22. T = sorted_data(k) * alpha;
  23. threshold(ii - left_num) = T;
  24. if T < signal(ii)
  25. position = [position, ii];
  26. end
  27. end
  28. function alpha = get_alpha(Pfa_set, N, k)
  29. % 用中点法求alpha_OS
  30. left_alpha = 0;
  31. while true
  32. right_alpha = left_alpha + 1;
  33. this_pfa = k * nchoosek(N, k) * beta(right_alpha + N - k + 1, k);
  34. if this_pfa < Pfa_set
  35. break;
  36. end
  37. left_alpha = right_alpha;
  38. end
  39. mid_alpha = 0.5 * (left_alpha + right_alpha);
  40. this_pfa = k * nchoosek(N, k) * beta(mid_alpha + N - k + 1, k);
  41. while abs(this_pfa - Pfa_set) > 0.000001 * Pfa_set
  42. if this_pfa > Pfa_set
  43. left_alpha = mid_alpha;
  44. else
  45. right_alpha = mid_alpha;
  46. end
  47. mid_alpha = 0.5 * (left_alpha + right_alpha);
  48. this_pfa = k * nchoosek(N, k) * beta(mid_alpha + N - k + 1, k);
  49. end
  50. % this_pfa
  51. alpha = mid_alpha;
  52. return
  53. return

MATLAB仿真结果:

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/我家小花儿/article/detail/720567
推荐阅读
相关标签
  

闽ICP备14008679号