RadarSignalGenerator.cpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  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: RadarSignalGenerator.cpp
  6. //
  7. // MATLAB Coder version : 5.3
  8. // C/C++ source code generated on : 25-Apr-2023 21:10:09
  9. //
  10. // Include Files
  11. #include "RadarSignalGenerator.h"
  12. #include "LinearFMWaveform.h"
  13. #include "../rt_nonfinite.h"
  14. #include <cmath>
  15. // Function Definitions
  16. //
  17. // RADARSIGNALGENERATOR1 此处显示有关此函数的摘要
  18. // 此处显示详细说明
  19. //
  20. // Arguments : double sig[400000]
  21. // double *fs
  22. // double *PRF
  23. // Return Type : void
  24. //
  25. void RadarSignalGenerator001(double sig[400000], double *fs, double *PRF)
  26. {
  27. static creal_T xt[80000];
  28. static double dv[80000];
  29. coder::phased::LinearFMWaveform wavGen;
  30. // simTime = 2e-5;
  31. *fs = 4.0E+9;
  32. *PRF = 49999.999999999993;
  33. wavGen.isInitialized = 0;
  34. wavGen.matlabCodegenIsDeleted = false;
  35. // 相位编码定义
  36. // 每次迭代产生一次脉冲数据,算出仿真时间内的脉冲数
  37. // numPulses = fix(simTime*PRF);
  38. for (int ii{0}; ii < 5; ii++) {
  39. double kd;
  40. int k;
  41. // 迭代波形
  42. wavGen.step(xt);
  43. // 载波调制
  44. dv[0] = 0.0;
  45. dv[79999] = 1.999975E-5;
  46. for (k = 0; k < 39998; k++) {
  47. kd = (static_cast<double>(k) + 1.0) * 2.5E-10;
  48. dv[k + 1] = kd;
  49. dv[79998 - k] = 1.999975E-5 - kd;
  50. }
  51. dv[39999] = 9.99975E-6;
  52. dv[40000] = 1.0E-5;
  53. for (k = 0; k < 80000; k++) {
  54. double b_re_tmp;
  55. double im;
  56. double re;
  57. double re_tmp;
  58. im = dv[k] * 6.2831853071795864E+9;
  59. if (im == 0.0) {
  60. kd = 1.0;
  61. im = 0.0;
  62. } else {
  63. kd = std::cos(im);
  64. im = std::sin(im);
  65. }
  66. re_tmp = xt[k].re;
  67. b_re_tmp = xt[k].im;
  68. re = re_tmp * kd - b_re_tmp * im;
  69. xt[k].re = re;
  70. xt[k].im = re_tmp * im + b_re_tmp * kd;
  71. sig[k + 80000 * ii] = re;
  72. }
  73. }
  74. }
  75. //
  76. // File trailer for RadarSignalGenerator.cpp
  77. //
  78. // [EOF]
  79. //