FMCWWaveform401.cpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  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: FMCWWaveform401.cpp
  6. //
  7. // MATLAB Coder version : 5.3
  8. // C/C++ source code generated on : 27-Apr-2023 00:06:45
  9. //
  10. // Include Files
  11. #include "FMCWWaveform401.h"
  12. #include "../rt_nonfinite.h"
  13. #include "../coder_array.h"
  14. #include <cmath>
  15. #include <cstring>
  16. // Function Definitions
  17. //
  18. // Arguments : void
  19. // Return Type : void
  20. //
  21. namespace coder {
  22. namespace phased {
  23. void FMCWWaveform401::setupImpl()
  24. {
  25. static const double dv[3]{2.0E-6, 3.0E-6, 4.0E-6};
  26. array<creal_T, 1U> r1;
  27. array<double, 1U> a;
  28. array<double, 1U> c_y;
  29. array<int, 2U> b_r;
  30. array<int, 2U> b_y;
  31. array<int, 2U> y;
  32. std::memset(&pSamples[0], 0, 180000U * sizeof(creal_T));
  33. for (int m{0}; m < 3; m++) {
  34. double r;
  35. int k;
  36. int nx;
  37. int vlen;
  38. if (m == 0) {
  39. nx = 0;
  40. } else {
  41. nx = m;
  42. }
  43. nx *= 20000;
  44. y.set_size(1, nx + 40000);
  45. for (k = 0; k <= nx + 39999; k++) {
  46. y[k] = k;
  47. }
  48. if (1 > m) {
  49. vlen = 0;
  50. } else {
  51. vlen = m;
  52. }
  53. if (m == 0) {
  54. nx = 0;
  55. } else {
  56. nx = m;
  57. }
  58. nx *= 20000;
  59. b_y.set_size(1, nx + 40000);
  60. for (k = 0; k <= nx + 39999; k++) {
  61. b_y[k] = k + 1;
  62. }
  63. if (vlen == 0) {
  64. r = 0.0;
  65. } else {
  66. r = 40000.0;
  67. for (k = 2; k <= vlen; k++) {
  68. r += 60000.0;
  69. }
  70. }
  71. b_r.set_size(1, b_y.size(1));
  72. nx = b_y.size(1);
  73. for (k = 0; k < nx; k++) {
  74. b_r[k] = static_cast<int>(static_cast<double>(b_y[k]) + r);
  75. }
  76. if (m == 0) {
  77. nx = 0;
  78. } else {
  79. nx = m;
  80. }
  81. r = 1.0E+9 / dv[nx] * 3.1415926535897931;
  82. a.set_size(y.size(1));
  83. nx = y.size(1);
  84. for (k = 0; k < nx; k++) {
  85. a[k] = static_cast<double>(y[k]) / 2.0E+10;
  86. }
  87. c_y.set_size(a.size(0));
  88. nx = a.size(0);
  89. for (k = 0; k < nx; k++) {
  90. c_y[k] = a[k] * a[k];
  91. }
  92. r1.set_size(c_y.size(0));
  93. nx = c_y.size(0);
  94. for (k = 0; k < nx; k++) {
  95. r1[k].re = 0.0;
  96. r1[k].im = c_y[k] * r;
  97. }
  98. nx = r1.size(0);
  99. for (k = 0; k < nx; k++) {
  100. if (r1[k].im == 0.0) {
  101. r1[k].re = std::exp(r1[k].re);
  102. r1[k].im = 0.0;
  103. } else if (std::isinf(r1[k].im) && std::isinf(r1[k].re) &&
  104. (r1[k].re < 0.0)) {
  105. r1[k].re = 0.0;
  106. r1[k].im = 0.0;
  107. } else {
  108. r = std::exp(r1[k].re / 2.0);
  109. r1[k].re = r * (r * std::cos(r1[k].im));
  110. r1[k].im = r * (r * std::sin(r1[k].im));
  111. }
  112. }
  113. nx = b_r.size(1);
  114. for (k = 0; k < nx; k++) {
  115. pSamples[b_r[k] - 1] = r1[k];
  116. }
  117. }
  118. }
  119. } // namespace phased
  120. } // namespace coder
  121. //
  122. // File trailer for FMCWWaveform401.cpp
  123. //
  124. // [EOF]
  125. //