// // 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 #include // Function Definitions // // Arguments : double fd // double N // double ts // double Tr // double t_r // double tau // double fo // double k // coder::array &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 &S) { coder::array b_b; coder::array Signal_Radar; coder::array 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(std::floor(b / ts)); S.set_size(1, ncols + 1); for (ntilecols = 0; ntilecols <= ncols; ntilecols++) { S[ntilecols] = ts * static_cast(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(std::floor(b / ts)); S.set_size(1, ncols + 1); for (ntilecols = 0; ntilecols <= ncols; ntilecols++) { S[ntilecols] = ts * static_cast(ntilecols); } } else { coder::eml_float_colon(ts, b, S); } Signal_Radar.set_size(1, rect.size(1) * static_cast(N)); ncols = rect.size(1); ntilecols = static_cast(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(Signal_Radar[ntilecols]) * S[ntilecols]; } } //int main() //{ // coder::array 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; //}