RadarSignalGenerator203.cpp 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  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: RadarSignalGenerator203.cpp
  6. //
  7. // MATLAB Coder version : 5.3
  8. // C/C++ source code generated on : 26-Apr-2023 23:54:03
  9. //
  10. // Include Files
  11. #include "RadarSignalGenerator203.h"
  12. #include "PhaseCodedWaveform203.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 RadarSignalGenerator203(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::PhaseCodedWaveform203 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.TunablePropsChanged = false;
  64. wavGen.pOutputPulseInterval[0] = 0.0;
  65. wavGen.pOutputPulseInterval[1] = 1.0;
  66. }
  67. std::memset(&xt[0], 0, 40000U * sizeof(creal_T));
  68. coder::phased::PhaseCodedWaveform203::getMatchingWaveform(unusedExpr);
  69. std::copy(&unusedExpr[0], &unusedExpr[10000], &xt[0]);
  70. coder::phased::PhaseCodedWaveform203::getMatchingWaveform(unusedExpr);
  71. // 载波调制
  72. b_xt[0] = 0.0;
  73. b_xt[39999] = 1.99995E-6;
  74. for (loop_ub_tmp = 0; loop_ub_tmp < 19998; loop_ub_tmp++) {
  75. kd = (static_cast<double>(loop_ub_tmp) + 1.0) * 5.0E-11;
  76. b_xt[loop_ub_tmp + 1] = kd;
  77. b_xt[39998 - loop_ub_tmp] = 1.99995E-6 - kd;
  78. }
  79. b_xt[19999] = 9.9995E-7;
  80. b_xt[20000] = 9.9999999999999974E-7;
  81. for (loop_ub_tmp = 0; loop_ub_tmp < 40000; loop_ub_tmp++) {
  82. double b_re_tmp;
  83. double im;
  84. double re_tmp;
  85. im = b_xt[loop_ub_tmp] * 5.969026041820607E+10;
  86. if (im == 0.0) {
  87. kd = 1.0;
  88. im = 0.0;
  89. } else {
  90. kd = std::cos(im);
  91. im = std::sin(im);
  92. }
  93. re_tmp = xt[loop_ub_tmp].re;
  94. b_re_tmp = xt[loop_ub_tmp].im;
  95. xt[loop_ub_tmp].re = re_tmp * kd - b_re_tmp * im;
  96. xt[loop_ub_tmp].im = re_tmp * im + b_re_tmp * kd;
  97. }
  98. if (idx > (idx + 40000.0) - 1.0) {
  99. i = -1;
  100. i1 = -39999;
  101. } else {
  102. i = static_cast<int>(idx) - 2;
  103. i1 = static_cast<int>(static_cast<unsigned int>(idx));
  104. }
  105. for (loop_ub_tmp = 0; loop_ub_tmp < 40000; loop_ub_tmp++) {
  106. b_xt[loop_ub_tmp] = xt[loop_ub_tmp].re;
  107. }
  108. loop_ub_tmp = (i1 - i) + 39998;
  109. for (i1 = 0; i1 < loop_ub_tmp; i1++) {
  110. sig[(i + i1) + 1] = b_xt[i1];
  111. }
  112. idx += 40000.0;
  113. }
  114. wavGen.matlabCodegenDestructor();
  115. *fs = 2.0E+10;
  116. *PRF = 500000.0;
  117. }
  118. //
  119. // File trailer for RadarSignalGenerator203.cpp
  120. //
  121. // [EOF]
  122. //