123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185 |
- //
- // File: fun6.cpp
- //
- // MATLAB Coder version : 5.2
- // C/C++ source code generated on : 04-Mar-2023 17:31:12
- //
- // Include Files
- #include "fun6.h"
- #include "coder_array.h"
- #include <cmath>
- #include <iostream>
- using namespace std;
- // Function Definitions
- //
- // Arguments : const coder::array<double, 1U> &pulse_sig
- // int tgt_idx
- // double fs
- // double forward_time_length
- // double forward_times
- // coder::array<double, 2U> &rxsig_noise
- // Return Type : void
- //
- void Slice_forward_interference(const coder::array<double, 1U> &pulse_sig, int tgt_idx, double fs,
- double forward_time_length, double forward_times,
- coder::array<double, 2U> &rxsig_noise)
- {
- coder::array<double, 2U> pulse_sig_noise_t;
- coder::array<double, 2U> varargin_2;
- coder::array<double, 1U> y;
- coder::array<unsigned int, 2U> r;
- coder::array<boolean_T, 1U> x;
- double idx1;
- double unnamed_idx_0;
- unsigned int idx_data;
- int ii_data;
- int ii_size;
- int k;
- int ntilerows;
- int nx;
- if (pulse_sig.size(0) > 100) {
- boolean_T exitg1;
- nx = pulse_sig.size(0);
- y.set_size(pulse_sig.size(0));
- for (k = 0; k < nx; k++) {
- y[k] = std::abs(pulse_sig[k]);
- }
- x.set_size(y.size(0));
- nx = y.size(0);
- for (k = 0; k < nx; k++) {
- x[k] = (y[k] > 0.0);
- }
- nx = 0;
- ii_size = 1;
- ntilerows = 0;
- exitg1 = false;
- while ((!exitg1) && (ntilerows <= x.size(0) - 1)) {
- if (x[ntilerows]) {
- nx = 1;
- ii_data = ntilerows + 1;
- exitg1 = true;
- } else {
- ntilerows++;
- }
- }
- if (nx == 0) {
- ii_size = 0;
- }
- for (k = 0; k < ii_size; k++) {
- idx_data = static_cast<unsigned int>(ii_data);
- }
- }
- idx1 = static_cast<double>(idx_data) + std::round(fs * 5.0E-7);
- unnamed_idx_0 = std::round(fs * forward_time_length);
- r.set_size(1, static_cast<int>(unnamed_idx_0) + 1);
- nx = static_cast<int>(unnamed_idx_0);
- for (k = 0; k <= nx; k++) {
- r[k] = static_cast<unsigned int>(idx1 + static_cast<double>(k));
- }
- unnamed_idx_0 = idx1 + static_cast<double>(r.size(1));
- varargin_2.set_size(r.size(1) * static_cast<int>(forward_times), 1);
- nx = r.size(1);
- ntilerows = static_cast<int>(forward_times);
- for (ii_size = 0; ii_size < ntilerows; ii_size++) {
- ii_data = ii_size * nx;
- for (k = 0; k < nx; k++) {
- varargin_2[ii_data + k] = pulse_sig[static_cast<int>(r[k]) - 1];
- }
- }
- if (static_cast<int>(unnamed_idx_0) != 0) {
- ntilerows = static_cast<int>(unnamed_idx_0);
- } else {
- ntilerows = 0;
- }
- if (varargin_2.size(0) != 0) {
- nx = varargin_2.size(0);
- } else {
- nx = 0;
- }
- pulse_sig_noise_t.set_size(ntilerows + nx, 1);
- for (k = 0; k < ntilerows; k++) {
- pulse_sig_noise_t[k] = 0.0;
- }
- for (k = 0; k < nx; k++) {
- pulse_sig_noise_t[k + ntilerows] = varargin_2[k];
- }
- if (static_cast<double>(r.size(1)) * forward_times + idx1 >=
- pulse_sig.size(0)) {
- nx = pulse_sig.size(0);
- rxsig_noise.set_size(1, pulse_sig.size(0));
- for (k = 0; k < nx; k++) {
- rxsig_noise[rxsig_noise.size(0) * k] = pulse_sig_noise_t[k];
- }
- } else {
- nx = pulse_sig_noise_t.size(0);
- if (nx <= 1) {
- nx = 1;
- }
- if (pulse_sig_noise_t.size(0) == 0) {
- nx = 0;
- }
- if (pulse_sig.size(0) > nx) {
- nx = pulse_sig_noise_t.size(0);
- if (nx <= 1) {
- nx = 1;
- }
- if (pulse_sig_noise_t.size(0) == 0) {
- nx = 0;
- }
- nx = pulse_sig.size(0) - nx;
- } else {
- nx = 0;
- }
- if (pulse_sig_noise_t.size(0) != 0) {
- ntilerows = pulse_sig_noise_t.size(0);
- } else {
- ntilerows = 0;
- }
- if (nx == 0) {
- nx = 0;
- }
- rxsig_noise.set_size(ntilerows + nx, 1);
- for (k = 0; k < ntilerows; k++) {
- rxsig_noise[k] = pulse_sig_noise_t[k];
- }
- for (k = 0; k < nx; k++) {
- rxsig_noise[k + ntilerows] = 0.0;
- }
- }
- }
- static coder::array<double, 1U> argInit_Unboundedx1_real_T()
- {
- coder::array<double, 1U> result;
- // Set the size of the array.
- // Change this size to the value that the application requires.
- result.set_size(200);
- // Loop over the array to initialize each element.
- for (int idx0{0}; idx0 < result.size(0); idx0++) {
- // Set the value of the array element.
- // Change this value to the value that the application requires.
- result[idx0] = 2;
- }
- return result;
- }
- //int main()
- //{
- // coder::array<double, 2U> rxsig_noise;
- // coder::array<double, 1U> pulse_sig;
- // // Initialize function 'fun6' input arguments.
- // // Initialize function input argument 'pulse_sig'.
- // pulse_sig = argInit_Unboundedx1_real_T();
- // int tgt_idx = 1;
- // double fs = 10e6;
- // double forward_time_length = 2e-6;
- // double forward_times = 4;
- // // Call the entry-point 'fun6'.
- // Slice_forward_interference(pulse_sig, tgt_idx, fs, forward_time_length, forward_times, rxsig_noise);
- // cout << "rxsig_noise=" <<endl;
- // for (int i = 0; i < rxsig_noise.size(0); i++) {
- // std::cout << rxsig_noise[i] << " ";
- // }
- // return 0;
- //}
|