RadarSignalGenerator303.cpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. //
  2. // Academic License - for use in teaching, academic research, and meeting
  3. // course requirements at degree granting institutions only. Not for
  4. // government, commercial, or other organizational use.
  5. // File: RadarSignalGenerator303.cpp
  6. //
  7. // MATLAB Coder version : 5.3
  8. // C/C++ source code generated on : 27-Apr-2023 00:02:16
  9. //
  10. // Include Files
  11. #include "RadarSignalGenerator303.h"
  12. #include "LinearFMWaveform303.h"
  13. #include "../coder_array.h"
  14. #include <algorithm>
  15. #include <cmath>
  16. #include <cstring>
  17. // Function Definitions
  18. //
  19. // RADARSIGNALGENERATOR1 此处显示有关此函数的摘要
  20. // 此处显示详细说明
  21. //
  22. // Arguments : coder::array<double, 1U> &sig
  23. // double *fs
  24. // double *PRF
  25. // double *len
  26. // Return Type : void
  27. //
  28. void RadarSignalGenerator303(coder::array<double, 1U> &sig, double *fs,
  29. double *PRF, double *len)
  30. {
  31. static creal_T xt[40000];
  32. static double b_xt[40000];
  33. coder::phased::LinearFMWaveform303 wavGen;
  34. creal_T unusedExpr[10000];
  35. double idx;
  36. int i;
  37. int ii;
  38. int loop_ub_tmp;
  39. // simTime = 2e-5;
  40. wavGen.isInitialized = 0;
  41. wavGen.matlabCodegenIsDeleted = false;
  42. // 相位编码定义
  43. // 产生5个脉冲
  44. // numPulses = fix(simTime*PRF);
  45. *len = 0.0;
  46. for (ii = 0; ii < 5; ii++) {
  47. *len += 40000.0;
  48. }
  49. loop_ub_tmp = static_cast<int>(*len);
  50. sig.set_size(loop_ub_tmp);
  51. for (i = 0; i < loop_ub_tmp; i++) {
  52. sig[i] = 0.0;
  53. }
  54. idx = 1.0;
  55. wavGen.pOutputStartPulseIndex = 1.0;
  56. for (ii = 0; ii < 5; ii++) {
  57. double kd;
  58. int i1;
  59. // 迭代波形
  60. if (wavGen.isInitialized != 1) {
  61. wavGen.isInitialized = 1;
  62. wavGen.isSetupComplete = true;
  63. wavGen.pOutputPulseInterval[0] = 0.0;
  64. wavGen.pOutputPulseInterval[1] = 1.0;
  65. }
  66. std::memset(&xt[0], 0, 40000U * sizeof(creal_T));
  67. coder::phased::LinearFMWaveform303::getMatchingWaveform(unusedExpr);
  68. std::copy(&unusedExpr[0], &unusedExpr[10000], &xt[0]);
  69. coder::phased::LinearFMWaveform303::getMatchingWaveform(unusedExpr);
  70. // 载波调制
  71. b_xt[0] = 0.0;
  72. b_xt[39999] = 1.99995E-6;
  73. for (loop_ub_tmp = 0; loop_ub_tmp < 19998; loop_ub_tmp++) {
  74. kd = (static_cast<double>(loop_ub_tmp) + 1.0) * 5.0E-11;
  75. b_xt[loop_ub_tmp + 1] = kd;
  76. b_xt[39998 - loop_ub_tmp] = 1.99995E-6 - kd;
  77. }
  78. b_xt[19999] = 9.9995E-7;
  79. b_xt[20000] = 9.9999999999999974E-7;
  80. for (loop_ub_tmp = 0; loop_ub_tmp < 40000; loop_ub_tmp++) {
  81. double b_re_tmp;
  82. double im;
  83. double re_tmp;
  84. im = b_xt[loop_ub_tmp] * 5.969026041820607E+10;
  85. if (im == 0.0) {
  86. kd = 1.0;
  87. im = 0.0;
  88. } else {
  89. kd = std::cos(im);
  90. im = std::sin(im);
  91. }
  92. re_tmp = xt[loop_ub_tmp].re;
  93. b_re_tmp = xt[loop_ub_tmp].im;
  94. xt[loop_ub_tmp].re = re_tmp * kd - b_re_tmp * im;
  95. xt[loop_ub_tmp].im = re_tmp * im + b_re_tmp * kd;
  96. }
  97. if (idx > (idx + 40000.0) - 1.0) {
  98. i = -1;
  99. i1 = -39999;
  100. } else {
  101. i = static_cast<int>(idx) - 2;
  102. i1 = static_cast<int>(static_cast<unsigned int>(idx));
  103. }
  104. for (loop_ub_tmp = 0; loop_ub_tmp < 40000; loop_ub_tmp++) {
  105. b_xt[loop_ub_tmp] = xt[loop_ub_tmp].re;
  106. }
  107. loop_ub_tmp = (i1 - i) + 39998;
  108. for (i1 = 0; i1 < loop_ub_tmp; i1++) {
  109. sig[(i + i1) + 1] = b_xt[i1];
  110. }
  111. idx += 40000.0;
  112. }
  113. wavGen.matlabCodegenDestructor();
  114. *fs = 2.0E+10;
  115. *PRF = 500000.0;
  116. }
  117. //
  118. // File trailer for RadarSignalGenerator303.cpp
  119. //
  120. // [EOF]
  121. //