RadarSignalGenerator302.cpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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: RadarSignalGenerator302.cpp
  6. //
  7. // MATLAB Coder version : 5.3
  8. // C/C++ source code generated on : 26-Apr-2023 23:59:19
  9. //
  10. // Include Files
  11. #include "RadarSignalGenerator302.h"
  12. #include "LinearFMWaveform302.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 RadarSignalGenerator302(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::LinearFMWaveform302 wavGen;
  33. double idx;
  34. int i;
  35. int ii;
  36. int loop_ub_tmp;
  37. // simTime = 2e-5;
  38. wavGen.isInitialized = 0;
  39. wavGen.matlabCodegenIsDeleted = false;
  40. // 相位编码定义
  41. // 产生5个脉冲
  42. // numPulses = fix(simTime*PRF);
  43. *len = 0.0;
  44. for (ii = 0; ii < 5; ii++) {
  45. *len += 60000.0;
  46. }
  47. loop_ub_tmp = static_cast<int>(*len);
  48. sig.set_size(loop_ub_tmp);
  49. for (i = 0; i < loop_ub_tmp; i++) {
  50. sig[i] = 0.0;
  51. }
  52. idx = 1.0;
  53. for (ii = 0; ii < 5; ii++) {
  54. double kd;
  55. int i1;
  56. // 迭代波形
  57. wavGen.step(xt);
  58. // 载波调制
  59. b_xt[0] = 0.0;
  60. b_xt[59999] = 2.99995E-6;
  61. for (loop_ub_tmp = 0; loop_ub_tmp < 29998; loop_ub_tmp++) {
  62. kd = (static_cast<double>(loop_ub_tmp) + 1.0) * 5.0E-11;
  63. b_xt[loop_ub_tmp + 1] = kd;
  64. b_xt[59998 - loop_ub_tmp] = 2.99995E-6 - kd;
  65. }
  66. b_xt[29999] = 1.4999500000000001E-6;
  67. b_xt[30000] = 1.4999999999999998E-6;
  68. for (loop_ub_tmp = 0; loop_ub_tmp < 60000; loop_ub_tmp++) {
  69. double b_re_tmp;
  70. double im;
  71. double re_tmp;
  72. im = b_xt[loop_ub_tmp] * 5.969026041820607E+10;
  73. if (im == 0.0) {
  74. kd = 1.0;
  75. im = 0.0;
  76. } else {
  77. kd = std::cos(im);
  78. im = std::sin(im);
  79. }
  80. re_tmp = xt[loop_ub_tmp].re;
  81. b_re_tmp = xt[loop_ub_tmp].im;
  82. xt[loop_ub_tmp].re = re_tmp * kd - b_re_tmp * im;
  83. xt[loop_ub_tmp].im = re_tmp * im + b_re_tmp * kd;
  84. }
  85. if (idx > (idx + 60000.0) - 1.0) {
  86. i = -1;
  87. i1 = -59999;
  88. } else {
  89. i = static_cast<int>(idx) - 2;
  90. i1 = static_cast<int>(static_cast<unsigned int>(idx));
  91. }
  92. for (loop_ub_tmp = 0; loop_ub_tmp < 60000; loop_ub_tmp++) {
  93. b_xt[loop_ub_tmp] = xt[loop_ub_tmp].re;
  94. }
  95. loop_ub_tmp = (i1 - i) + 59998;
  96. for (i1 = 0; i1 < loop_ub_tmp; i1++) {
  97. sig[(i + i1) + 1] = b_xt[i1];
  98. }
  99. idx += 60000.0;
  100. }
  101. wavGen.matlabCodegenDestructor();
  102. *fs = 2.0E+10;
  103. *PRF = 333333.33333333331;
  104. }
  105. //
  106. // File trailer for RadarSignalGenerator302.cpp
  107. //
  108. // [EOF]
  109. //