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

📄 d_decoder_wrapper.c

📁 用simlink开发的space-time coding仿真模型,仿真的精度与效率有不小的提高
💻 C
字号:
/*
  *
  *   --- THIS FILE GENERATED BY S-FUNCTION BUILDER: 3.0 ---
  *
  *   This file is a wrapper S-function produced by the S-Function
  *   Builder which only recognizes certain fields.  Changes made
  *   outside these fields will be lost the next time the block is
  *   used to load, edit, and resave this file. This file will be overwritten
  *   by the S-function Builder block. If you want to edit this file by hand, 
  *   you must change it only in the area defined as:  
  *
  *        %%%-SFUNWIZ_wrapper_XXXXX_Changes_BEGIN 
  *            Your Changes go here
  *        %%%-SFUNWIZ_wrapper_XXXXXX_Changes_END
  *
  *   For better compatibility with the Real-Time Workshop, the
  *   "wrapper" S-function technique is used.  This is discussed
  *   in the Real-Time Workshop User's Manual in the Chapter titled,
  *   "Wrapper S-functions".
  *
  *   Created: Tue Sep  6 16:50:24 2005
  */


/*
 * Include Files
 *
 */
#if defined(MATLAB_MEX_FILE)
#include "tmwtypes.h"
#include "simstruc_types.h"
#else
#include "rtwtypes.h"
#endif
/* %%%-SFUNWIZ_wrapper_includes_Changes_BEGIN --- EDIT HERE TO _END */
#include <math.h>
/* %%%-SFUNWIZ_wrapper_includes_Changes_END --- EDIT HERE TO _BEGIN */
#define u_width 1
#define y_width 1
/*
 * Create external references here.  
 *
 */
/* %%%-SFUNWIZ_wrapper_externs_Changes_BEGIN --- EDIT HERE TO _END */
/* extern double func(double a); */
/* %%%-SFUNWIZ_wrapper_externs_Changes_END --- EDIT HERE TO _BEGIN */

/*
 * Output functions
 *
 */
void D_Decoder_Outputs_wrapper(const creal_T *R1,
                          const creal_T *R2,
                          real_T *y,
                          const real_T  *xD)
{
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_BEGIN --- EDIT HERE TO _END */
int V[2][4]={{1,0,0,-1},{0,1,-1,0}};
      int B[2][4]={{0,1,0,1},{0,0,1,1}};
      int m,id;
      double temp_min,dis1,dis2,DIS[4];
      
      for (m=0;m<4;m++){
          dis1=(R1[0].re-V[0][m])*(R1[0].re-V[0][m])+R1[0].im*R1[0].im;
          dis2=(R2[0].re-V[1][m])*(R2[0].re-V[1][m])+R2[0].im*R2[0].im;
          DIS[m]=sqrt(dis1)+sqrt(dis2) ;
      }
      id=0;
      temp_min=9999999;
      for (m=0;m<4;m++){
          if (DIS[m]<temp_min){
             temp_min=DIS[m];
             id=m;
          }
      }
      temp_min=fmod(xD[0]-1,65);
      if (temp_min!=0){
          y[0]=B[0][id];
          y[1]=B[1][id];         
      }
      else if (temp_min==0){
          y[0]=0;
          y[1]=0;
      }
      
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_END --- EDIT HERE TO _BEGIN */
}

/*
  * Updates function
  *
  */
void D_Decoder_Update_wrapper(const creal_T *R1,
                          const creal_T *R2,
                          const real_T *y,
                          real_T *xD)
{
  /* %%%-SFUNWIZ_wrapper_Update_Changes_BEGIN --- EDIT HERE TO _END */
 xD[0]=xD[0]+1;
/* %%%-SFUNWIZ_wrapper_Update_Changes_END --- EDIT HERE TO _BEGIN */
}

⌨️ 快捷键说明

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