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

📄 s_resize.c

📁 wcdma模型
💻 C
字号:
/* | Project:     WCDMA simulation environment | Module:       | Author:       | Date:        June 2, 1999 | | History: |              June 2, 1999 Maarit Melvasalo |                      Initial version         |              June 16, 1999 Maarit Melvasalo |                      Comments added | |  File    :  | |  Abstract:   Resizes the given input |              Removes  or adds 0 to the end or beginning of |              the input vector     | |       INPUTS: 1) input vector |       OUTPUT: 1) output vector | |  DEPENDS ON FILES  | | USER GIVEN PARAMETERS | | | Copyright disclaimer: |   This software was developed at the National Institute of Standards |   and Technology by employees of the Federal Government in the course |   of their official duties. Pursuant to title 17 Section 105 of the |   United States Code this software is not subject to copyright |   protection and is in the public domain. | |   We would appreciate acknowledgement if the software is used. |*/#define S_FUNCTION_NAME s_remove#define S_FUNCTION_LEVEL 2#include <math.h>#include "simstruc.h"#include "tmwtypes.h"#include "config_wcdma.h"#include "wcdma_simulink.h"/* USER GIVEN PARAMETERS AND DEFINITIONS /**//*Number of input and output ports/**/#define NINPUTS   1#define NOUTPUTS  1/* Number of user given parameters/**/ #define NPARAMS 4                      /* Input block size/**/#define IN_SIZE(S)  ssGetSFcnParam(S,0)          #define nIN (int_T)(mxGetPr(IN_SIZE(S))[0])/* out put block size /**/#define OUT_SIZE(S)  ssGetSFcnParam(S,1)         #define nOut (int_T)(mxGetPr(OUT_SIZE(S))[0]) /* In the end (1) or beginning  (2)/**/#define P_PARAM(S)  ssGetSFcnParam(S,1)         /* Sample time (comapred to TD_FRAME) /**/#define TIME(S) ssGetSFcnParam(S,3)   #define nTime (mxGetPr(TIME(S))[0]) /* Pointers to Input Ports */#define U(element) (*uPtrs[element])  /* Sampletime -- defined in config_cdma /**/#define td  nTime * TD_FRAME    /*====================* */static void mdlInitializeSizes(SimStruct *S){  ssSetNumSFcnParams(S, NPARAMS);  /* Number of expected parameters */  if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S))  {      return; }    if (!ssSetNumInputPorts(S, NINPUTS)) return;    ssSetInputPortWidth(S, 0, nIn);    ssSetInputPortDirectFeedThrough(S, 0, nSide);    if (!ssSetNumOutputPorts(S, NOUTPUTS)) return;    ssSetOutputPortWidth(S, 0, nOut);    ssSetNumSampleTimes(S, 1);    ssSetSFcnParamNotTunable(S,0);     ssSetSFcnParamNotTunable(S,1);     ssSetSFcnParamNotTunable(S,2);     /* Take care when specifying exception free code - see sfuntmpl.doc */    ssSetOptions(S, SS_OPTION_EXCEPTION_FREE_CODE);}   /* ei saa kayttaa mxCalloc tai mexErrMsgTxt tms rutiineita *//* Function: mdlInitializeSampleTimes ========================================= */static void mdlInitializeSampleTimes(SimStruct *S){  ssSetSampleTime(S, 0, td);   ssSetOffsetTime(S, 0, 0.0);}/* Function: mdlOutputs ======================================================= */static void mdlOutputs(SimStruct *S, int_T tid){  real_T            *y    = ssGetOutputPortRealSignal(S,0);  InputRealPtrsType uPtrs = ssGetInputPortRealSignalPtrs(S,0);  real_T            plaze  = mxGetPr(P_PARAM(S))[0];  int_T             i,s_min,s_diff;              /*    plaze == 1 if the bits are added or removed from the beginning    plaze == 2 if the bits are added or removed from the end    /**/  s_min = min(nIn,nOut);  if (plaze == 2) {    for (i = 0; i < s_min; i++)      y[i] = U(i);    if ( nOut > nIn  ) {      for (i = nIn; i <nOut  ; i++)	      y[i] = 0;    }      }  else {    s_diff = abs(nOut - nIn);    if ( nOut > nIn  ) {      for (i = 0; i < s_diff  ; i++)	      y[i] = 0;    }  }}/* Function: mdlTerminate ===================================================== */static void mdlTerminate(SimStruct *S){}#ifdef  MATLAB_MEX_FILE    /* Is this file being compiled as a MEX-file? */#include "simulink.c"      /* MEX-file interface mechanism */#else#include "cg_sfun.h"       /* Code generation registration function */#endif

⌨️ 快捷键说明

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