📄 signal_determination_wrapper.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: Sun Aug 21 19:41:48 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 2
#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 signal_determination_Outputs_wrapper(const real_T *h2,
const creal_T *x,
real_T *y0)
{
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_BEGIN --- EDIT HERE TO _END */
// -----this is for 16QAM-----//
/* double Constellations_re[16]={1,0.9239,0.7071,0.3827,0.0000,-0.3827,-0.7071,-0.9239,-1.0000,-0.9239,-0.7071,-0.3827,-0.0000,0.3827,0.7071,0.9239};
double Constellations_im[16]={0,0.3827,0.7071,0.9239,1.0000,0.9239,0.7071,0.3827,0.0000,-0.3827,-0.7071,-0.9239,-1.0000,-0.9239,-0.7071,-0.3827};
*/
// -----this is for 8-PSK (gray coding)------//
double Constellations_re[8]={1.0000,0.7071,0.0000,-0.7071,-1.0000,-0.7071,-0.0000,0.7071};
double Constellations_im[8]={0,0.7071,1.0000,0.7071,0.0000,-0.7071,-1.0000,-0.7071};
int SignalPoints[8]={0,1,3,2,6,7,5,4};
// ----this is for BPSK-----//
/* double Constellations_re[2]={1,-1};
double Constellations_im[2]={0,0};
//---- this is for QPSK-----//
/*double Constellations_re[4]={1,0,-1,0};
double Constellations_im[4]={0,1,0,-1};
int SignalPoints[4]={0,1,3,2};*/
double temp_h,temp_x[8],temp_d[8],temp1,temp2;
int m,n;
temp_h=0;
for (m=0;m<=1;m++)
{ temp_h=temp_h+h2[m];
}
temp_h=temp_h-1;
for (m=0;m<=7;m++)
{ temp_x[m]=Constellations_re[m]*Constellations_re[m]+Constellations_im[m]*Constellations_im[m];
temp_x[m]=temp_x[m]*temp_h;
}
for (m=0;m<=1;m++)
{ for (n=0;n<=7;n++)
{ temp1=x[m].re-Constellations_re[n];
temp2=x[m].im-Constellations_im[n];
temp_d[n]=temp1*temp1+temp2*temp2+temp_x[n];
}
temp1=999999;
for (n=0;n<=7;n++)
{ if (temp_d[n]<temp1)
{ temp1=temp_d[n];
y0[m]=SignalPoints[n];
}
}
}
/* %%%-SFUNWIZ_wrapper_Outputs_Changes_END --- EDIT HERE TO _BEGIN */
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -