RadarSignalGenerator102.cpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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: RadarSignalGenerator102.cpp
  6. //
  7. // MATLAB Coder version : 5.3
  8. // C/C++ source code generated on : 26-Apr-2023 23:37:46
  9. //
  10. // Include Files
  11. #include "RadarSignalGenerator102.h"
  12. #include "RectangularWaveform102.h"
  13. #include "../rt_nonfinite.h"
  14. #include "../coder_array.h"
  15. #include <cmath>
  16. // Function Definitions
  17. //
  18. // RADARSIGNALGENERATOR1 此处显示有关此函数的摘要
  19. // 此处显示详细说明
  20. //
  21. // Arguments : coder::array<double, 1U> &sig
  22. // double *fs
  23. // double *PRF
  24. // double *len
  25. // Return Type : void
  26. //
  27. void RadarSignalGenerator102(coder::array<double, 1U> &sig, double *fs,
  28. double *PRF, double *len)
  29. {
  30. static creal_T xt[60000];
  31. static double b_xt[60000];
  32. coder::phased::RectangularWaveform102 wavGen;
  33. double idx;
  34. int i;
  35. int ii;
  36. int loop_ub_tmp;
  37. // simTime = 2e-5;
  38. // 方波定义
  39. wavGen.isInitialized = 0;
  40. wavGen.matlabCodegenIsDeleted = false;
  41. // 线性调频波定义
  42. // 产生5个脉冲
  43. // numPulses = fix(simTime*PRF);
  44. *len = 0.0;
  45. for (ii = 0; ii < 5; ii++) {
  46. *len += 60000.0;
  47. }
  48. loop_ub_tmp = static_cast<int>(*len);
  49. sig.set_size(loop_ub_tmp);
  50. for (i = 0; i < loop_ub_tmp; i++) {
  51. sig[i] = 0.0;
  52. }
  53. idx = 1.0;
  54. for (ii = 0; ii < 5; ii++) {
  55. double kd;
  56. int i1;
  57. // 迭代波形
  58. wavGen.step(xt);
  59. // 载波调制
  60. b_xt[0] = 0.0;
  61. b_xt[59999] = 2.99995E-6;
  62. for (loop_ub_tmp = 0; loop_ub_tmp < 29998; loop_ub_tmp++) {
  63. kd = (static_cast<double>(loop_ub_tmp) + 1.0) * 5.0E-11;
  64. b_xt[loop_ub_tmp + 1] = kd;
  65. b_xt[59998 - loop_ub_tmp] = 2.99995E-6 - kd;
  66. }
  67. b_xt[29999] = 1.4999500000000001E-6;
  68. b_xt[30000] = 1.4999999999999998E-6;
  69. for (loop_ub_tmp = 0; loop_ub_tmp < 60000; loop_ub_tmp++) {
  70. double b_re_tmp;
  71. double im;
  72. double re_tmp;
  73. im = b_xt[loop_ub_tmp] * 5.969026041820607E+10;
  74. if (im == 0.0) {
  75. kd = 1.0;
  76. im = 0.0;
  77. } else {
  78. kd = std::cos(im);
  79. im = std::sin(im);
  80. }
  81. re_tmp = xt[loop_ub_tmp].re;
  82. b_re_tmp = xt[loop_ub_tmp].im;
  83. xt[loop_ub_tmp].re = re_tmp * kd - b_re_tmp * im;
  84. xt[loop_ub_tmp].im = re_tmp * im + b_re_tmp * kd;
  85. }
  86. if (idx > (idx + 60000.0) - 1.0) {
  87. i = -1;
  88. i1 = -59999;
  89. } else {
  90. i = static_cast<int>(idx) - 2;
  91. i1 = static_cast<int>(static_cast<unsigned int>(idx));
  92. }
  93. for (loop_ub_tmp = 0; loop_ub_tmp < 60000; loop_ub_tmp++) {
  94. b_xt[loop_ub_tmp] = xt[loop_ub_tmp].re;
  95. }
  96. loop_ub_tmp = (i1 - i) + 59998;
  97. for (i1 = 0; i1 < loop_ub_tmp; i1++) {
  98. sig[(i + i1) + 1] = b_xt[i1];
  99. }
  100. idx += 60000.0;
  101. }
  102. wavGen.matlabCodegenDestructor();
  103. *fs = 2.0E+10;
  104. *PRF = 333333.33333333331;
  105. }
  106. //
  107. // File trailer for RadarSignalGenerator102.cpp
  108. //
  109. // [EOF]
  110. //