⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 c2_mymethod0.c

📁 mmo 信道估计算法 matlab 仿真 实现了无线信道环境下的信道估计
💻 C
📖 第 1 页 / 共 3 页
字号:
  /*   */
  /*   */
  /*   */
  /*   */
  /*   */
  /*   */
  /*   */
  /*   */
  /*   */
  /*   */
  /*   */
  /*   */
  /*   */
  /*   */
  /*   */
  /*  %    % Calculate the delayd correlation */
  /*  %    delay_xcorr = rx_signal(:,1:search_win+2*D).*conj(rx_signal(:,1*D+1:search_win+3*D)); */
  /*  %        */
  /*  %    % Moving average of the delayed correlation */
  /*  %    ma_delay_xcorr = abs(filter(ones(1,2*D), 1, delay_xcorr, [], 2)); */
  /*  %     */
  /*  %    % Moving average of received power */
  /*  %    ma_rx_pwr = filter(ones(1,2*D), 1, abs(rx_signal(:,1*D+1:search_win+3*D)).^2,[], 2); */
  /*  %     */
  /*  %    % The decision variable */
  /*  %    delay_len = length(ma_delay_xcorr); */
  /*  %    ma_M = ma_delay_xcorr(:,1:delay_len)./ma_rx_pwr(:,1:delay_len); */
  /*  %           */
  /*  %    % remove delay samples */
  /*  %    ma_M(:,1:2*D) = []; */
  /*  %     */
  /*  %    % combine antennas, if rx diversity is used */
  /*  %    ma_M = sum(ma_M, 1); */
  /*  %     */
  /*  %    if ~sim_options.UseRxDiv */
  /*  %       threshold = 0.75; */
  /*  %    else */
  /*  %       threshold = 1.5; */
  /*  %    end */
  /*  %     */
  /*  %    thres_idx = find(ma_M > threshold); */
  /*  %    if isempty(thres_idx) */
  /*  %       thres_idx = 1; */
  /*  %    else */
  /*  %       thres_idx = thres_idx(1); */
  /*  %    end */
  /*  %     */
  /*  % else */
  /*  %    thres_idx = sim_consts.ExtraNoiseSamples; */
  /*  end; */
  /*   */
  /*  % check if the packet has been detected too late,  */
  /*  % > sim_consts.extra_noise_samples + 35 index  */
  /*  % is out of range of the fine timing algorithm */
  /*  % This prevents simulation error for code running out samples */
  /*  if thres_idx > sim_consts.ExtraNoiseSamples + 35 */
  /*     thres_idx = 1; */
  /*  end */
  /*   */
  /*  detected_packet = rx_signal(:,thres_idx:length(rx_signal)); */
  _SFD_EML_CALL(STATE_DURING_DURING_ACTION_TAG,0,-39);
  sf_debug_symbol_scope_pop();
}

static real_T c2_abs(creal_T c2_x)
{
  real_T c2_x1;
  real_T c2_x2;
  real_T c2_a;
  real_T c2_b;
  real_T c2_b_x;
  real_T c2_b_y;
  real_T c2_c_x;
  real_T c2_c_y;
  c2_x1 = c2_x.re;
  c2_x2 = c2_x.im;
  c2_a = fabs(c2_x1);
  c2_b = fabs(c2_x2);
  if(c2_a == 0.0) {
    return c2_b;
  } else if(c2_b == 0.0) {
    return c2_a;
  } else if(c2_a == c2_b) {
    return c2_a * 1.4142135623730951E+000;
  } else if(c2_b > c2_a) {
    c2_b_x = c2_a;
    c2_b_y = c2_b;
    c2_a = c2_b_x / c2_b_y;
    return c2_b * sqrt(1.0 + c2_a * c2_a);
  } else {
    c2_c_x = c2_b;
    c2_c_y = c2_a;
    c2_b = c2_c_x / c2_c_y;
    return c2_a * sqrt(1.0 + c2_b * c2_b);
  }
}

static real_T c2_mpower(real_T c2_a)
{
  real_T c2_b_a;
  real_T c2_ak;
  c2_b_a = c2_a;
  c2_ak = c2_b_a;
  return pow(c2_ak, 2.0);
}

static const mxArray *c2_sf_marshall(void *c2_chartInstance, void *c2_u)
{
  const mxArray *c2_y = NULL;
  creal_T c2_b_u;
  const mxArray *c2_b_y = NULL;
  c2_y = NULL;
  c2_b_u.re = ((creal_T *)c2_u)->re;
  c2_b_u.im = ((creal_T *)c2_u)->im;
  c2_b_y = NULL;
  sf_mex_assign(&c2_b_y, sf_mex_create(&c2_b_u, "y", 0, 1U, 0U, 0));
  sf_mex_assign(&c2_y, c2_b_y);
  return c2_y;
}

static const mxArray *c2_b_sf_marshall(void *c2_chartInstance, void *c2_u)
{
  const mxArray *c2_y = NULL;
  int32_T c2_i11;
  creal_T c2_b_u[480];
  const mxArray *c2_b_y = NULL;
  c2_y = NULL;
  for(c2_i11 = 0; c2_i11 < 480; c2_i11 = c2_i11 + 1) {
    c2_b_u[c2_i11].re = (*(creal_T (*)[480])c2_u)[c2_i11].re;
    c2_b_u[c2_i11].im = (*(creal_T (*)[480])c2_u)[c2_i11].im;
  }
  c2_b_y = NULL;
  sf_mex_assign(&c2_b_y, sf_mex_create(&c2_b_u, "y", 0, 1U, 1U, 1, 480));
  sf_mex_assign(&c2_y, c2_b_y);
  return c2_y;
}

static const mxArray *c2_c_sf_marshall(void *c2_chartInstance, void *c2_u)
{
  const mxArray *c2_y = NULL;
  int32_T c2_i12;
  creal_T c2_b_u[480];
  const mxArray *c2_b_y = NULL;
  c2_y = NULL;
  for(c2_i12 = 0; c2_i12 < 480; c2_i12 = c2_i12 + 1) {
    c2_b_u[c2_i12].re = (*(creal_T (*)[480])c2_u)[c2_i12].re;
    c2_b_u[c2_i12].im = (*(creal_T (*)[480])c2_u)[c2_i12].im;
  }
  c2_b_y = NULL;
  sf_mex_assign(&c2_b_y, sf_mex_create(&c2_b_u, "y", 0, 1U, 1U, 1, 480));
  sf_mex_assign(&c2_y, c2_b_y);
  return c2_y;
}

static const mxArray *c2_d_sf_marshall(void *c2_chartInstance, void *c2_u)
{
  const mxArray *c2_y = NULL;
  int32_T c2_i13;
  real_T c2_b_u[200];
  const mxArray *c2_b_y = NULL;
  c2_y = NULL;
  for(c2_i13 = 0; c2_i13 < 200; c2_i13 = c2_i13 + 1) {
    c2_b_u[c2_i13] = (*(real_T (*)[200])c2_u)[c2_i13];
  }
  c2_b_y = NULL;
  sf_mex_assign(&c2_b_y, sf_mex_create(&c2_b_u, "y", 0, 0U, 1U, 1, 200));
  sf_mex_assign(&c2_y, c2_b_y);
  return c2_y;
}

static const mxArray *c2_e_sf_marshall(void *c2_chartInstance, void *c2_u)
{
  const mxArray *c2_y = NULL;
  int32_T c2_i14;
  real_T c2_b_u[200];
  const mxArray *c2_b_y = NULL;
  c2_y = NULL;
  for(c2_i14 = 0; c2_i14 < 200; c2_i14 = c2_i14 + 1) {
    c2_b_u[c2_i14] = (*(real_T (*)[200])c2_u)[c2_i14];
  }
  c2_b_y = NULL;
  sf_mex_assign(&c2_b_y, sf_mex_create(&c2_b_u, "y", 0, 0U, 1U, 1, 200));
  sf_mex_assign(&c2_y, c2_b_y);
  return c2_y;
}

static const mxArray *c2_f_sf_marshall(void *c2_chartInstance, void *c2_u)
{
  const mxArray *c2_y = NULL;
  real_T c2_b_u;
  const mxArray *c2_b_y = NULL;
  c2_y = NULL;
  c2_b_u = *(real_T *)c2_u;
  c2_b_y = NULL;
  sf_mex_assign(&c2_b_y, sf_mex_create(&c2_b_u, "y", 0, 0U, 0U, 0));
  sf_mex_assign(&c2_y, c2_b_y);
  return c2_y;
}

static const mxArray *c2_g_sf_marshall(void *c2_chartInstance, void *c2_u)
{
  const mxArray *c2_y = NULL;
  real_T c2_b_u;
  const mxArray *c2_b_y = NULL;
  c2_y = NULL;
  c2_b_u = *(real_T *)c2_u;
  c2_b_y = NULL;
  sf_mex_assign(&c2_b_y, sf_mex_create(&c2_b_u, "y", 0, 0U, 0U, 0));
  sf_mex_assign(&c2_y, c2_b_y);
  return c2_y;
}

static const mxArray *c2_h_sf_marshall(void *c2_chartInstance, void *c2_u)
{
  const mxArray *c2_y = NULL;
  int32_T c2_i15;
  creal_T c2_b_u[480];
  const mxArray *c2_b_y = NULL;
  c2_y = NULL;
  for(c2_i15 = 0; c2_i15 < 480; c2_i15 = c2_i15 + 1) {
    c2_b_u[c2_i15].re = (*(creal_T (*)[480])c2_u)[c2_i15].re;
    c2_b_u[c2_i15].im = (*(creal_T (*)[480])c2_u)[c2_i15].im;
  }
  c2_b_y = NULL;
  sf_mex_assign(&c2_b_y, sf_mex_create(&c2_b_u, "y", 0, 1U, 1U, 1, 480));
  sf_mex_assign(&c2_y, c2_b_y);
  return c2_y;
}

static const mxArray *c2_i_sf_marshall(void *c2_chartInstance, void *c2_u)
{
  const mxArray *c2_y = NULL;
  int32_T c2_i16;
  creal_T c2_b_u[480];
  const mxArray *c2_b_y = NULL;
  c2_y = NULL;
  for(c2_i16 = 0; c2_i16 < 480; c2_i16 = c2_i16 + 1) {
    c2_b_u[c2_i16].re = (*(creal_T (*)[480])c2_u)[c2_i16].re;
    c2_b_u[c2_i16].im = (*(creal_T (*)[480])c2_u)[c2_i16].im;
  }
  c2_b_y = NULL;
  sf_mex_assign(&c2_b_y, sf_mex_create(&c2_b_u, "y", 0, 1U, 1U, 1, 480));
  sf_mex_assign(&c2_y, c2_b_y);
  return c2_y;
}

static const mxArray *c2_j_sf_marshall(void *c2_chartInstance, void *c2_u)
{
  const mxArray *c2_y = NULL;
  int32_T c2_i17;
  real_T c2_b_u[40];
  const mxArray *c2_b_y = NULL;
  c2_y = NULL;
  for(c2_i17 = 0; c2_i17 < 40; c2_i17 = c2_i17 + 1) {
    c2_b_u[c2_i17] = (*(real_T (*)[40])c2_u)[c2_i17];
  }
  c2_b_y = NULL;
  sf_mex_assign(&c2_b_y, sf_mex_create(&c2_b_u, "y", 0, 0U, 1U, 2, 1, 40));
  sf_mex_assign(&c2_y, c2_b_y);
  return c2_y;
}

static const mxArray *c2_k_sf_marshall(void *c2_chartInstance, void *c2_u)
{
  const mxArray *c2_y = NULL;
  real_T c2_b_u;
  const mxArray *c2_b_y = NULL;
  c2_y = NULL;
  c2_b_u = *(real_T *)c2_u;
  c2_b_y = NULL;
  sf_mex_assign(&c2_b_y, sf_mex_create(&c2_b_u, "y", 0, 0U, 0U, 0));
  sf_mex_assign(&c2_y, c2_b_y);
  return c2_y;
}

static const mxArray *c2_l_sf_marshall(void *c2_chartInstance, void *c2_u)
{
  const mxArray *c2_y = NULL;
  real_T c2_b_u;
  const mxArray *c2_b_y = NULL;
  c2_y = NULL;
  c2_b_u = *(real_T *)c2_u;
  c2_b_y = NULL;
  sf_mex_assign(&c2_b_y, sf_mex_create(&c2_b_u, "y", 0, 0U, 0U, 0));
  sf_mex_assign(&c2_y, c2_b_y);
  return c2_y;
}

static const mxArray *c2_m_sf_marshall(void *c2_chartInstance, void *c2_u)
{
  const mxArray *c2_y = NULL;
  real_T c2_b_u;
  const mxArray *c2_b_y = NULL;
  c2_y = NULL;
  c2_b_u = *(real_T *)c2_u;
  c2_b_y = NULL;
  sf_mex_assign(&c2_b_y, sf_mex_create(&c2_b_u, "y", 0, 0U, 0U, 0));
  sf_mex_assign(&c2_y, c2_b_y);
  return c2_y;
}

static const mxArray *c2_n_sf_marshall(void *c2_chartInstance, void *c2_u)
{
  const mxArray *c2_y = NULL;
  creal_T c2_b_u;
  const mxArray *c2_b_y = NULL;
  c2_y = NULL;
  c2_b_u.re = ((creal_T *)c2_u)->re;
  c2_b_u.im = ((creal_T *)c2_u)->im;
  c2_b_y = NULL;
  sf_mex_assign(&c2_b_y, sf_mex_create(&c2_b_u, "y", 0, 1U, 0U, 0));
  sf_mex_assign(&c2_y, c2_b_y);
  return c2_y;
}

static const mxArray *c2_o_sf_marshall(void *c2_chartInstance, void *c2_u)
{
  const mxArray *c2_y = NULL;
  real_T c2_b_u;
  const mxArray *c2_b_y = NULL;
  c2_y = NULL;
  c2_b_u = *(real_T *)c2_u;
  c2_b_y = NULL;
  sf_mex_assign(&c2_b_y, sf_mex_create(&c2_b_u, "y", 0, 0U, 0U, 0));
  sf_mex_assign(&c2_y, c2_b_y);
  return c2_y;
}

static const mxArray *c2_p_sf_marshall(void *c2_chartInstance, void *c2_u)
{
  const mxArray *c2_y = NULL;
  real_T c2_b_u;
  const mxArray *c2_b_y = NULL;
  c2_y = NULL;
  c2_b_u = *(real_T *)c2_u;
  c2_b_y = NULL;
  sf_mex_assign(&c2_b_y, sf_mex_create(&c2_b_u, "y", 0, 0U, 0U, 0));
  sf_mex_assign(&c2_y, c2_b_y);
  return c2_y;
}

static const mxArray *c2_q_sf_marshall(void *c2_chartInstance, void *c2_u)
{
  const mxArray *c2_y = NULL;
  int32_T c2_i18;
  real_T c2_b_u[200];
  const mxArray *c2_b_y = NULL;
  c2_y = NULL;
  for(c2_i18 = 0; c2_i18 < 200; c2_i18 = c2_i18 + 1) {
    c2_b_u[c2_i18] = (*(real_T (*)[200])c2_u)[c2_i18];
  }
  c2_b_y = NULL;
  sf_mex_assign(&c2_b_y, sf_mex_create(&c2_b_u, "y", 0, 0U, 1U, 2, 1, 200));
  sf_mex_assign(&c2_y, c2_b_y);
  return c2_y;
}

static const mxArray *c2_r_sf_marshall(void *c2_chartInstance, void *c2_u)
{
  const mxArray *c2_y = NULL;
  int32_T c2_i19;
  real_T c2_b_u[200];
  const mxArray *c2_b_y = NULL;
  c2_y = NULL;
  for(c2_i19 = 0; c2_i19 < 200; c2_i19 = c2_i19 + 1) {
    c2_b_u[c2_i19] = (*(real_T (*)[200])c2_u)[c2_i19];
  }
  c2_b_y = NULL;
  sf_mex_assign(&c2_b_y, sf_mex_create(&c2_b_u, "y", 0, 0U, 1U, 2, 1, 200));
  sf_mex_assign(&c2_y, c2_b_y);
  return c2_y;
}

static const mxArray *c2_s_sf_marshall(void *c2_chartInstance, void *c2_u)
{
  const mxArray *c2_y = NULL;
  real_T c2_b_u;
  const mxArray *c2_b_y = NULL;
  c2_y = NULL;
  c2_b_u = *(real_T *)c2_u;
  c2_b_y = NULL;
  sf_mex_assign(&c2_b_y, sf_mex_create(&c2_b_u, "y", 0, 0U, 0U, 0));
  sf_mex_assign(&c2_y, c2_b_y);
  return c2_y;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -