123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156 |
- //
- // File: S_orignal_2.cpp
- //
- // MATLAB Coder version : 5.2
- // C/C++ source code generated on : 05-Mar-2023 15:19:40
- //
- // Include Files
- #include "fun5.h"
- #include "colon.h"
- #include "rt_nonfinite.h"
- #include "coder_array.h"
- #include <cmath>
- #include <iostream>
- // Function Definitions
- //
- // Arguments : double fd
- // double N
- // double ts
- // double Tr
- // double t_r
- // double tau
- // double fo
- // double k
- // coder::array<double, 2U> &S
- // Return Type : void
- //
- void S_orignal_2(double fd, double N, double ts, double Tr, double t_r, double tau,
- double fo, double k, coder::array<double, 2U> &S)
- {
- coder::array<double, 2U> b_b;
- coder::array<signed char, 2U> Signal_Radar;
- coder::array<signed char, 2U> rect;
- double a;
- double b;
- double b_a;
- int ncols;
- int ntilecols;
- b = Tr - ts;
- if (std::isnan(ts) || std::isnan(b)) {
- S.set_size(1, 1);
- S[0] = rtNaN;
- } else if ((ts == 0.0) || ((0.0 < b) && (ts < 0.0)) ||
- ((b < 0.0) && (ts > 0.0))) {
- S.set_size(1, 0);
- } else if (std::isinf(b) && (std::isinf(ts) || (0.0 == b))) {
- S.set_size(1, 1);
- S[0] = rtNaN;
- } else if (std::isinf(ts)) {
- S.set_size(1, 1);
- S[0] = 0.0;
- } else if (std::floor(ts) == ts) {
- ncols = static_cast<int>(std::floor(b / ts));
- S.set_size(1, ncols + 1);
- for (ntilecols = 0; ntilecols <= ncols; ntilecols++) {
- S[ntilecols] = ts * static_cast<double>(ntilecols);
- }
- } else {
- coder::eml_float_colon(ts, b, S);
- }
- rect.set_size(1, S.size(1));
- ncols = S.size(1);
- for (ntilecols = 0; ntilecols < ncols; ntilecols++) {
- rect[ntilecols] = 0;
- }
- ntilecols = S.size(1);
- for (ncols = 0; ncols < ntilecols; ncols++) {
- b = S[ncols];
- if ((b >= t_r) && (b <= tau + t_r)) {
- rect[ncols] = 1;
- }
- }
- b = N * Tr - ts;
- if (std::isnan(ts) || std::isnan(b)) {
- S.set_size(1, 1);
- S[0] = rtNaN;
- } else if ((ts == 0.0) || ((0.0 < b) && (ts < 0.0)) ||
- ((b < 0.0) && (ts > 0.0))) {
- S.set_size(S.size(0), 0);
- } else if (std::isinf(b) && (std::isinf(ts) || (0.0 == b))) {
- S.set_size(1, 1);
- S[0] = rtNaN;
- } else if (std::isinf(ts)) {
- S.set_size(1, 1);
- S[0] = 0.0;
- } else if (std::floor(ts) == ts) {
- ncols = static_cast<int>(std::floor(b / ts));
- S.set_size(1, ncols + 1);
- for (ntilecols = 0; ntilecols <= ncols; ntilecols++) {
- S[ntilecols] = ts * static_cast<double>(ntilecols);
- }
- } else {
- coder::eml_float_colon(ts, b, S);
- }
- Signal_Radar.set_size(1, rect.size(1) * static_cast<int>(N));
- ncols = rect.size(1);
- ntilecols = static_cast<int>(N);
- for (int jtilecol{0}; jtilecol < ntilecols; jtilecol++) {
- int ibtile;
- ibtile = jtilecol * ncols;
- for (int jcol{0}; jcol < ncols; jcol++) {
- Signal_Radar[ibtile + jcol] = rect[jcol];
- }
- }
- a = 6.2831853071795862 * (fo + fd);
- S.set_size(1, S.size(1));
- ncols = S.size(1) - 1;
- for (ntilecols = 0; ntilecols <= ncols; ntilecols++) {
- S[ntilecols] = S[ntilecols] - t_r;
- }
- b_a = 3.1415926535897931 * k;
- b_b.set_size(1, S.size(1));
- ncols = S.size(1);
- for (ntilecols = 0; ntilecols < ncols; ntilecols++) {
- b = S[ntilecols];
- b_b[ntilecols] = b * b;
- }
- S.set_size(1, S.size(1));
- ncols = S.size(1) - 1;
- for (ntilecols = 0; ntilecols <= ncols; ntilecols++) {
- S[ntilecols] = a * S[ntilecols] + b_a * b_b[ntilecols];
- }
- ncols = S.size(1);
- for (ntilecols = 0; ntilecols < ncols; ntilecols++) {
- S[ntilecols] = std::cos(S[ntilecols]);
- }
- S.set_size(1, Signal_Radar.size(1));
- ncols = Signal_Radar.size(1) - 1;
- for (ntilecols = 0; ntilecols <= ncols; ntilecols++) {
- S[ntilecols] = static_cast<double>(Signal_Radar[ntilecols]) * S[ntilecols];
- }
- }
- //int main()
- //{
- // coder::array<double, 2U> S;
- // double fd = 40;
- // double N = 1;
- // double ts = 1.0000e-07;
- // double Tr = 4.0000e-04;
- // double t_r = 2.0000e-04;
- // double tau = 1.0000e-04;
- // double fo = 1e6;
- // double k = 1.0000e+11;
- //
- // // Call the entry-point 'S_orignal_2'.
- // S_orignal_2(fd, N, ts, Tr, t_r, tau, fo, k, S);
- // // 输出结果
- // for (int i = 0; i < S.size(1); i++) {
- // std::cout << S[i] << " ";
- // }
- // std::cout << std::endl;
- // return 0;
- //}
|