123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422 |
- //
- // Academic License - for use in teaching, academic research, and meeting
- // course requirements at degree granting institutions only. Not for
- // government, commercial, or other organizational use.
- // File: multifx.cpp
- //
- // MATLAB Coder version : 5.3
- // C/C++ source code generated on : 27-Mar-2023 15:34:32
- //
- // Include Files
- #include "fun10_multifx.h"
- #include "fun10_distcal.h"
- #include "fun10_histcounts.h"
- #include "rt_nonfinite.h"
- #include "fun10_sort.h"
- #include "coder_array.h"
- #include <algorithm>
- #include <cmath>
- // Type Definitions
- struct emxArray_real_T_1x25 {
- double data[25];
- int size[2];
- };
- struct cell_wrap_0 {
- emxArray_real_T_1x25 f1;
- };
- // Function Definitions
- //
- // MULTIFX 多站时差分选
- // 此处显示详细说明
- // %% 1. 数据生成
- // 做传输时间
- //
- // Arguments : const coder::array<double, 2U> &RadarCart
- // const coder::array<double, 2U> &ZCPlatCart
- // double N_data[]
- // int N_size[2]
- // double edges_data[]
- // int edges_size[2]
- // Return Type : void
- //
- void multifx(const coder::array<double, 2U> &RadarCart,
- const coder::array<double, 2U> &ZCPlatCart, double N_data[],
- int N_size[2], double edges_data[], int edges_size[2])
- {
- static const double PulseITime[25]{0.0001,
- 0.0002,
- 0.00030000000000000003,
- 0.0004,
- 0.0005,
- 0.00060000000000000006,
- 0.0007000000000000001,
- 0.0008,
- 0.00090000000000000008,
- 0.001,
- 0.0011,
- 0.0012000000000000001,
- 0.0013,
- 0.0014,
- 0.0015,
- 0.0015999999999999999,
- 0.0017000000000000001,
- 0.0018,
- 0.0019,
- 0.002,
- 0.0021,
- 0.0022,
- 0.0023,
- 0.0024000000000000002,
- 0.0025};
- static const double PulseCTime[16]{0.00013, 0.00043999999999999996,
- 0.00075, 0.00106,
- 0.00137, 0.00168,
- 0.00199, 0.0023,
- 0.00031, 0.00062,
- 0.00093, 0.00124,
- 0.00155, 0.00186,
- 0.00217, 0.00248};
- static const double PulseDTime[16]{0.00012,
- 0.00045,
- 0.00078,
- 0.00111,
- 0.0014399999999999999,
- 0.0017699999999999999,
- 0.0021,
- 0.00243,
- 0.00033,
- 0.00066,
- 0.00099,
- 0.00132,
- 0.00165,
- 0.00198,
- 0.00231,
- 0.00264};
- static const double PulseGTime[16]{0.00015,
- 0.0003,
- 0.00045,
- 0.0006,
- 0.00074999999999999991,
- 0.00089999999999999987,
- 0.00105,
- 0.0012,
- 0.0013499999999999999,
- 0.0014999999999999998,
- 0.00165,
- 0.0018,
- 0.00195,
- 0.0021,
- 0.00225,
- 0.0024};
- static const double PulseFTime[15]{0.00016,
- 0.00032,
- 0.00048000000000000007,
- 0.00064,
- 0.0008,
- 0.00096,
- 0.0011200000000000001,
- 0.00128,
- 0.00144,
- 0.0016000000000000003,
- 0.0017600000000000003,
- 0.0019200000000000003,
- 0.0020800000000000003,
- 0.0022400000000000002,
- 0.0024000000000000002};
- coder::array<double, 2U> TDOARecordYY;
- coder::array<double, 2U> TOAA;
- coder::array<double, 2U> TOAB;
- coder::array<double, 2U> TransTime;
- cell_wrap_0 RadarPulseTime[7];
- cell_wrap_0 r;
- cell_wrap_0 r1;
- cell_wrap_0 r2;
- cell_wrap_0 r3;
- cell_wrap_0 r4;
- cell_wrap_0 r5;
- cell_wrap_0 r6;
- double dv[16];
- double RadarCart_data[3];
- double ZCPlatCart_data[3];
- double RadarTotal;
- double TDOAWindow;
- int RadarCart_size[2];
- int ZCPlatCart_size[2];
- unsigned int TOAAcnt;
- int b_i;
- int b_u1;
- int c_u1;
- int i;
- int loop_ub;
- int n;
- int u0;
- int u1;
- if ((ZCPlatCart.size(0) == 0) || (ZCPlatCart.size(1) == 0)) {
- n = 1;
- } else if (ZCPlatCart.size(0) > ZCPlatCart.size(1)) {
- n = ZCPlatCart.size(0) + 1;
- } else {
- n = ZCPlatCart.size(1) + 1;
- }
- if ((RadarCart.size(0) == 0) || (RadarCart.size(1) == 0)) {
- u1 = 0;
- } else {
- u0 = RadarCart.size(0);
- u1 = RadarCart.size(1);
- if (u0 >= u1) {
- u1 = u0;
- }
- }
- TransTime.set_size(n, u1);
- n *= u1;
- for (i = 0; i < n; i++) {
- TransTime[i] = 0.0;
- }
- if ((ZCPlatCart.size(0) == 0) || (ZCPlatCart.size(1) == 0)) {
- u1 = 0;
- } else {
- u0 = ZCPlatCart.size(0);
- u1 = ZCPlatCart.size(1);
- if (u0 >= u1) {
- u1 = u0;
- }
- if ((RadarCart.size(0) == 0) || (RadarCart.size(1) == 0)) {
- b_u1 = 0;
- } else {
- u0 = RadarCart.size(0);
- b_u1 = RadarCart.size(1);
- if (u0 >= b_u1) {
- b_u1 = u0;
- }
- }
- }
- for (b_i = 0; b_i < u1; b_i++) {
- if (0 <= b_u1 - 1) {
- n = ZCPlatCart.size(1);
- ZCPlatCart_size[0] = 1;
- ZCPlatCart_size[1] = ZCPlatCart.size(1);
- loop_ub = RadarCart.size(1);
- RadarCart_size[0] = 1;
- RadarCart_size[1] = RadarCart.size(1);
- for (i = 0; i < n; i++) {
- ZCPlatCart_data[i] = ZCPlatCart[b_i + ZCPlatCart.size(0) * i];
- }
- }
- for (u0 = 0; u0 < b_u1; u0++) {
- for (i = 0; i < loop_ub; i++) {
- RadarCart_data[i] = RadarCart[u0 + RadarCart.size(0) * i];
- }
- TransTime[b_i + TransTime.size(0) * u0] =
- b_distcal(ZCPlatCart_data, ZCPlatCart_size, RadarCart_data,
- RadarCart_size) /
- 2.99792458E+8;
- }
- }
- if ((RadarCart.size(0) == 0) || (RadarCart.size(1) == 0)) {
- u1 = 0;
- } else {
- u0 = RadarCart.size(0);
- u1 = RadarCart.size(1);
- if (u0 >= u1) {
- u1 = u0;
- }
- if ((ZCPlatCart.size(0) == 0) || (ZCPlatCart.size(1) == 0)) {
- c_u1 = 0;
- } else {
- u0 = ZCPlatCart.size(0);
- c_u1 = ZCPlatCart.size(1);
- if (u0 >= c_u1) {
- c_u1 = u0;
- }
- }
- }
- for (u0 = 0; u0 < u1; u0++) {
- TransTime[c_u1 + TransTime.size(0) * u0] =
- TransTime[TransTime.size(0) * u0] -
- TransTime[TransTime.size(0) * u0 + 1];
- }
- // %% 2. 时差窗
- // 理论时差窗
- n = ZCPlatCart.size(1);
- ZCPlatCart_size[0] = 1;
- ZCPlatCart_size[1] = ZCPlatCart.size(1);
- for (i = 0; i < n; i++) {
- ZCPlatCart_data[i] = ZCPlatCart[ZCPlatCart.size(0) * i];
- }
- n = ZCPlatCart.size(1);
- RadarCart_size[0] = 1;
- RadarCart_size[1] = ZCPlatCart.size(1);
- for (i = 0; i < n; i++) {
- RadarCart_data[i] = ZCPlatCart[ZCPlatCart.size(0) * i + 1];
- }
- // 考虑误差
- TDOAWindow = b_distcal(ZCPlatCart_data, ZCPlatCart_size, RadarCart_data,
- RadarCart_size) /
- 2.99792458E+8 +
- 1.7E-8;
- // %% 3. 脉冲流计算
- // 仿真时间
- // 辐射源c: 130us 180us二参差
- // 辐射源d:120us 210us二参差
- // 辐射源e: 170us
- // 辐射源f: 160us
- // 辐射源g: 150us
- // 辐射源h: 140us
- // 辐射源i: 100us
- std::copy(&PulseCTime[0], &PulseCTime[16], &dv[0]);
- coder::internal::sort(dv);
- r.f1.size[0] = 1;
- r.f1.size[1] = 16;
- for (i = 0; i < 16; i++) {
- r.f1.data[i] = dv[i];
- dv[i] = PulseDTime[i];
- }
- coder::internal::sort(dv);
- r1.f1.size[0] = 1;
- r1.f1.size[1] = 16;
- std::copy(&dv[0], &dv[16], &r1.f1.data[0]);
- r2.f1.size[0] = 1;
- r2.f1.size[1] = 14;
- for (i = 0; i < 14; i++) {
- r2.f1.data[i] = 0.00017 * static_cast<double>(i) + 0.00017;
- }
- r3.f1.size[0] = 1;
- r3.f1.size[1] = 15;
- std::copy(&PulseFTime[0], &PulseFTime[15], &r3.f1.data[0]);
- r4.f1.size[0] = 1;
- r4.f1.size[1] = 16;
- std::copy(&PulseGTime[0], &PulseGTime[16], &r4.f1.data[0]);
- r5.f1.size[0] = 1;
- r5.f1.size[1] = 17;
- for (i = 0; i < 17; i++) {
- r5.f1.data[i] = 0.00014 * static_cast<double>(i) + 0.00014;
- }
- r6.f1.size[0] = 1;
- r6.f1.size[1] = 25;
- std::copy(&PulseITime[0], &PulseITime[25], &r6.f1.data[0]);
- RadarPulseTime[0] = r;
- RadarPulseTime[1] = r1;
- RadarPulseTime[2] = r2;
- RadarPulseTime[3] = r3;
- RadarPulseTime[4] = r4;
- RadarPulseTime[5] = r5;
- RadarPulseTime[6] = r6;
- // %% 4. 脉冲序列
- RadarTotal = 0.0;
- for (b_i = 0; b_i < 7; b_i++) {
- RadarTotal += static_cast<double>(RadarPulseTime[b_i].f1.size[1]);
- }
- n = static_cast<int>(RadarTotal);
- TOAA.set_size(1, n);
- for (i = 0; i < n; i++) {
- TOAA[i] = 0.0;
- }
- TOAAcnt = 0U;
- // 主站
- for (b_i = 0; b_i < 7; b_i++) {
- i = RadarPulseTime[b_i].f1.size[1];
- for (u0 = 0; u0 < i; u0++) {
- RadarTotal =
- RadarPulseTime[b_i].f1.data[u0] + TransTime[TransTime.size(0) * b_i];
- if (RadarTotal <= 0.0025) {
- TOAAcnt++;
- TOAA[static_cast<int>(TOAAcnt) - 1] = RadarTotal;
- }
- }
- }
- if (1 > static_cast<int>(TOAAcnt)) {
- i = 0;
- } else {
- i = static_cast<int>(TOAAcnt);
- }
- TOAA.set_size(TOAA.size(0), i);
- // 副站
- TOAB.set_size(1, n);
- for (i = 0; i < n; i++) {
- TOAB[i] = 0.0;
- }
- TOAAcnt = 0U;
- for (b_i = 0; b_i < 7; b_i++) {
- i = RadarPulseTime[b_i].f1.size[1];
- for (u0 = 0; u0 < i; u0++) {
- RadarTotal = RadarPulseTime[b_i].f1.data[u0] +
- TransTime[TransTime.size(0) * b_i + 1];
- if (RadarTotal <= 0.0025) {
- TOAAcnt++;
- TOAB[static_cast<int>(TOAAcnt) - 1] = RadarTotal;
- }
- }
- }
- if (1 > static_cast<int>(TOAAcnt)) {
- i = 0;
- } else {
- i = static_cast<int>(TOAAcnt);
- }
- TOAB.set_size(TOAB.size(0), i);
- // figure
- // subplot(1,2,1)
- // stem(TOAA,ones(1,TOAAcnt));
- // subplot(1,2,2)
- // stem(TOAB,ones(TOABcnt,1));
- // %% 5. 求时差
- coder::internal::sort(TOAA);
- coder::internal::sort(TOAB);
- TOAAcnt = 0U;
- TDOARecordYY.set_size(1, static_cast<int>(static_cast<double>(TOAA.size(1)) *
- static_cast<double>(TOAB.size(1))));
- n = static_cast<int>(static_cast<double>(TOAA.size(1)) *
- static_cast<double>(TOAB.size(1)));
- for (i = 0; i < n; i++) {
- TDOARecordYY[i] = 0.0;
- }
- i = TOAA.size(1);
- for (b_i = 0; b_i < i; b_i++) {
- n = TOAB.size(1);
- for (u0 = 0; u0 < n; u0++) {
- RadarTotal = TOAA[b_i] - TOAB[u0];
- if (std::abs(RadarTotal) <= TDOAWindow) {
- TOAAcnt++;
- TDOARecordYY[static_cast<int>(TOAAcnt) - 1] = RadarTotal;
- }
- }
- }
- if (1 > static_cast<int>(TOAAcnt)) {
- i = 0;
- } else {
- i = static_cast<int>(TOAAcnt);
- }
- TDOARecordYY.set_size(TDOARecordYY.size(0), i);
- // figure
- // scatter(TDOARecordXX,TDOARecordYY,'filled');
- // hold on
- //
- // XX = 0:0.1e-6:simTime;
- // for i = 1:7
- // YY = linspace(TransTime(3,i),TransTime(3,i),length(XX));
- // plot(XX,YY);
- // hold on
- // end
- // %% 6. 直方图
- // for i = 1:length(TDOARecordYY)
- // TDOARecordYY(i) = round(TDOARecordYY(i),8);
- // end
- // figure
- // histogram(TDOARecordYY,25);
- coder::histcounts(TDOARecordYY, N_data, N_size, edges_data, edges_size);
- // for i = 1:length(N)
- // if (N(i) >= 5)
- // disp([num2str(edges(i)),'~',num2str(edges(i+1)),':
- // ',num2str(N(i))]);
- // end
- // end
- }
- //
- // File trailer for multifx.cpp
- //
- // [EOF]
- //
|