亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? homopuls.c

?? 介紹了通信系統中各個通信模塊的MATLAB實現
?? C
字號:
/* $Revision: 1.23 $ */
/*
 * HOMOPULS   A Simulink homonic pulse generator.
 *
 *           Syntax:  [sys, x0] = homopuls(t,x,u,flag,sample,divider,offset)
 *
 * Wes Wang  8/18/1994 revised 1/24/1996.
 * Copyright 1996-2001 The MathWorks, Inc.
 */

#define S_FUNCTION_NAME homopuls

#ifdef MATLAB_MEX_FILE
#include "mex.h"      /* needed for declaration of mexErrMsgTxt */
#endif

/*
 * need to include simstruc.h for the definition of the SimStruct and
 * its associated macro definitions.
 */

#include "simstruc.h"
#include "tmwtypes.h"
#include <math.h>

/* For RTW */
#if defined(RT) || defined(NRT)  
#undef  mexPrintf
#define mexPrintf printf
#endif

/*
 * Defines for easy access of the input parameters
 */

#define NUM_ARGS     3
#define SAMPLE_TIME       ssGetArg(S,0)
#define DIVIDER_EACH      ssGetArg(S,1)
#define OFFSET_EACH       ssGetArg(S,2)

/*
 * mdlInitializeSizes - called to initialize the sizes array stored in
 *                      the SimStruct.  The sizes array defines the
 *                      characteristics (number of inputs, outputs,
 *                      states, etc.) of the S-Function.
 */

static int_T isclose(real_T a, real_T b)
{
#define EPS       4.656612875245797e-10    /*  reciprocal of 2^31-1 */
     real_T diff;

#ifdef MATLAB_MEX_FILE
    if (0) {
      char_T err_msg[255];
      sprintf(err_msg, "a %f, b %f \n", a, b);
      mexPrintf(err_msg);
    } 
#endif
    
     diff = fabs(a - b);
     if (diff * 1.e-5 /(fabs(a) + EPS) < EPS)
       return(1);
     else
       return(0);
}

static void mdlInitializeSizes(SimStruct *S)
{
  /*
   * Set-up size information.
   */ 
  int_T NumSampleTime;

  if (ssGetNumArgs(S) == NUM_ARGS) {
    int_T dividerSize;
    if ((mxGetN(SAMPLE_TIME) * mxGetM(SAMPLE_TIME)) > 1) {
#ifdef MATLAB_MEX_FILE
      mexErrMsgTxt("The sample time is a scalar.");
#endif
    }
    
    if ((mxGetN(DIVIDER_EACH) != 1) && (mxGetM(DIVIDER_EACH) != 1)) {
#ifdef MATLAB_MEX_FILE
      mexErrMsgTxt("The divider must be a vector");
#endif
    }
               
    if ((mxGetN(OFFSET_EACH) != 1) && (mxGetM(OFFSET_EACH) != 1)) {
#ifdef MATLAB_MEX_FILE
      mexErrMsgTxt("The offset must be a vector");
#endif
    }
               
    if ((mxGetN(OFFSET_EACH) * (mxGetM(OFFSET_EACH))) != ((mxGetN(DIVIDER_EACH) * (mxGetM(DIVIDER_EACH))))) {
#ifdef MATLAB_MEX_FILE
      mexErrMsgTxt("Divider and Offset must have the same length");
#endif
    }
    
    dividerSize = mxGetN(DIVIDER_EACH) * mxGetM(DIVIDER_EACH);
    NumSampleTime = dividerSize;
    if (dividerSize > 0) {
       real_T sampleTime, sampleTimeI, offsetTimeI;
       int_T    adj, i;
       real_T *past_sample, *past_offset;
       
       past_sample = (real_T *)calloc(dividerSize, sizeof(real_T));
       past_offset = (real_T *)calloc(dividerSize, sizeof(real_T));

       sampleTime = mxGetPr(SAMPLE_TIME)[0];
       NumSampleTime = 0;
       for (i=0; i < dividerSize; i++) {
         offsetTimeI = mxGetPr(OFFSET_EACH)[i];
         sampleTimeI = sampleTime/2./mxGetPr(DIVIDER_EACH)[i];
         if (sampleTimeI <= 0) {
#ifdef MATLAB_MEX_FILE
	     mexErrMsgTxt("Sample time must be positive number.");
#endif
         }
         while  (offsetTimeI < 0)
            offsetTimeI += sampleTimeI;
         adj = (int_T)(offsetTimeI / sampleTimeI);
         offsetTimeI = offsetTimeI - ((real_T)adj) * sampleTimeI;

#ifdef MATLAB_MEX_FILE
         if (0) {
           char_T err_msg[255];
           sprintf(err_msg, "Iteration %d, offsetTimeI %f, sampleTimeI %f \n", i, offsetTimeI, sampleTimeI);
           mexPrintf(err_msg);
         }     
#endif

	 if ((isclose(offsetTimeI, 0.0)) || (isclose(offsetTimeI, sampleTimeI)))
	   offsetTimeI = 0;
	 if (i > 0) {
	   int_T test_flag, ii;
	   test_flag = 1;
	   for (ii = 0; ii<NumSampleTime; ii++) {
#ifdef MATLAB_MEX_FILE
          if (0) {
               char_T err_msg[255];
               sprintf(err_msg, "sampleTimeI %f, past_sample[ii] %f, offsetTimeI %f, past_offset[ii] %f \n", sampleTimeI, past_sample[ii], offsetTimeI, past_offset[ii]);
               mexPrintf(err_msg);
	  }
#endif
	     if ((isclose(sampleTimeI, past_sample[ii])) && (isclose(offsetTimeI, past_offset[ii])))
	        test_flag = 0;
	   }
	   if (test_flag) {
	     past_sample[NumSampleTime] = sampleTimeI;
             past_offset[NumSampleTime] = offsetTimeI;
	     NumSampleTime++;
	   }
	 } else {
	   past_sample[NumSampleTime] = sampleTimeI;
	   past_offset[NumSampleTime] = offsetTimeI;
           NumSampleTime++;
	 }
       }
       free(past_sample);
       free(past_offset);
    }
#ifdef MATLAB_MEX_FILE     
    if (0) {
      char_T err_msg[255];
      sprintf(err_msg, "NumSampleTime %d: \n", NumSampleTime);
      mexPrintf(err_msg);
    }
#endif

    ssSetNumContStates(    S, 0);
    ssSetNumDiscStates(    S, 0);
    ssSetNumInputs(        S, 0);
    ssSetNumOutputs(       S, dividerSize);
    ssSetDirectFeedThrough(S, 0);
    ssSetNumInputArgs(     S, NUM_ARGS);
    ssSetNumSampleTimes(   S, NumSampleTime);
    ssSetNumRWork(         S, 4*dividerSize+2); /* store the timing */
    ssSetNumIWork(         S, dividerSize); /* store the last time access. */
    ssSetNumPWork(         S, 0);
  } else {
#ifdef MATLAB_MEX_FILE
    char_T err_msg[256];
    sprintf(err_msg, "Wrong number of input arguments passed to S-function MEX-file.\n %d input arguments were passed in when expecting %d input arguments.\n", ssGetNumArgs(S) + 4, NUM_ARGS + 4);
    mexErrMsgTxt(err_msg);
#endif
  }
}

/*
 * mdlInitializeSampleTimes - initializes the array of sample times stored in
 *                            the SimStruct associated with this S-Function.
 */

static void mdlInitializeSampleTimes(SimStruct *S)
{
  int_T dividerSize, NumSampleTime;
  int_T NumSmpTm = ssGetNumSampleTimes(S);

  dividerSize = mxGetN(DIVIDER_EACH) * mxGetM(DIVIDER_EACH);

  NumSampleTime = dividerSize;
  if (dividerSize > 0) {
    real_T sampleTime, sampleTimeI, offsetTimeI;
    int_T    adj, i;
    real_T *past_sample, *past_offset;
       
    past_sample = (real_T *)calloc(dividerSize, sizeof(real_T));
    past_offset = (real_T *)calloc(dividerSize, sizeof(real_T));

    sampleTime = mxGetPr(SAMPLE_TIME)[0];
    NumSampleTime = 0;
    for (i=0; i < dividerSize; i++) {
      offsetTimeI = mxGetPr(OFFSET_EACH)[i];
      sampleTimeI = sampleTime/2./mxGetPr(DIVIDER_EACH)[i];
      while  (offsetTimeI < 0)
         offsetTimeI += sampleTimeI;

      adj = (int_T)(offsetTimeI / sampleTimeI);
      offsetTimeI = offsetTimeI - ((real_T)adj) * sampleTimeI;
      if ((isclose(offsetTimeI, 0.0)) || (isclose(offsetTimeI, sampleTimeI)))
	offsetTimeI = 0;
      while  (offsetTimeI > sampleTimeI)
        offsetTimeI -= sampleTimeI;
      if (i > 0) {
	int_T test_flag, ii;
	test_flag = 1;
	for (ii = 0; ii<NumSampleTime; ii++) {
	  if ((isclose(sampleTimeI, past_sample[ii])) && (isclose(offsetTimeI, past_offset[ii])))
	    test_flag = 0;
	}
	if (test_flag) {
	  past_sample[NumSampleTime] = sampleTimeI;
          past_offset[NumSampleTime] = offsetTimeI;
#ifdef MATLAB_MEX_FILE
	  if (0) {
	      char_T err_msg[255];
	      sprintf(err_msg, "Sample Time: %f, Offset Time: %f\n", sampleTimeI, offsetTimeI);
	      mexPrintf(err_msg);
	  } 
#endif    
          ssSetSampleTimeEvent(S, NumSampleTime, sampleTimeI);
          ssSetOffsetTimeEvent(S, NumSampleTime, offsetTimeI);
	  NumSampleTime++;
	}
      } else {
	past_sample[NumSampleTime] = sampleTimeI;
	past_offset[NumSampleTime] = offsetTimeI;
#ifdef MATLAB_MEX_FILE
	if (0) {
	    char_T err_msg[255];
	    sprintf(err_msg, "Sample Time: %f, Offset Time: %f", sampleTimeI, offsetTimeI);
	    mexPrintf(err_msg);
        }     
#endif
        ssSetSampleTimeEvent(S, NumSampleTime, sampleTimeI);
        ssSetOffsetTimeEvent(S, NumSampleTime, offsetTimeI);
        NumSampleTime++;
      }
      if (NumSampleTime > NumSmpTm) {
#ifdef MATLAB_MEX_FILE
        mexErrMsgTxt("Check your sample time and offset time. It is not consistant.");
#endif
      }
    }
    free(past_sample);
    free(past_offset);
  }
#ifdef MATLAB_MEX_FILE
  if (0) {
      char_T err_msg[255];
      sprintf(err_msg, "NumSampleTime %d: \n", NumSampleTime);
      mexPrintf(err_msg);
  }
#endif
    ssSetNumContStates(    S, 0);
    ssSetNumDiscStates(    S, 0);
}

/*
 * mdlInitializeConditions - initializes the states for the S-Function
 */

static void mdlInitializeConditions(real_T *x0, SimStruct *S)
{

  int_T dividerSize = mxGetN(DIVIDER_EACH) * mxGetM(DIVIDER_EACH);
  int_T offsetSize  = mxGetN(OFFSET_EACH) * mxGetM(OFFSET_EACH);

  real_T *hit_base   = ssGetRWork(S);
  real_T *next_hit   = ssGetRWork(S) + 1;    
  real_T *last_value = ssGetRWork(S) + dividerSize + 1;
  real_T *increment  = ssGetRWork(S) + dividerSize * 2 + 1;
  real_T *adj_offset = ssGetRWork(S) + dividerSize * 3 + 1;
  real_T *tolerance  = ssGetRWork(S) + dividerSize * 4 + 1;
  int_T  *reverse    = ssGetIWork(S);        
  real_T  sampleTime, offsetTime, offsetMin, tmp, tol;
  int_T   i, adj;
  
  dividerSize = (dividerSize < offsetSize) ? dividerSize : offsetSize;

  offsetMin = mxGetPr(OFFSET_EACH)[0];
  sampleTime = mxGetPr(SAMPLE_TIME)[0];
  /* 
   * Initialize the last_accs to all zeros.
   */
  tol = sampleTime;
  for (i = 0; i < dividerSize; i++) {
    *last_value++ = 0.;
    
    offsetTime = mxGetPr(OFFSET_EACH)[i];        
    offsetMin = (offsetMin < offsetTime) ? offsetMin : offsetTime;
    
    next_hit[i] = offsetTime;
    
    tmp = sampleTime/2./mxGetPr(DIVIDER_EACH)[i];
    increment[i] = tmp;
    
    tol = (tol < tmp) ? tol : tmp;
    
    adj = (int_T)(offsetTime / tmp);
    tmp = offsetTime - ((real_T)adj) * tmp;

    /*
    if (isclose(tmp, 0.0)) {
      reverse[i] = 0;
    } else if (isclose(tmp, offsetTime - ((real_T)(((int_T)(offsetTime/tmp/2)))) * tmp * 2)) {
    mexPrintf("offsetTime=%f, increment[%d]=%f.",offsetTime,i,increment[i]);
    */

    if (increment[i] > offsetTime - 2 * increment[i] * floor(offsetTime/2./increment[i])) {
      reverse[i] = 0;
    } else {
      reverse[i] = 1;
    }
#ifdef MATLAB_MEX_FILE
    if (0) {
      char_T err_msg[255];
      sprintf(err_msg, "reverse[%d]=%d; \n", i, reverse[i]);
      mexPrintf(err_msg);
    }
#endif
    adj_offset[i] = tmp;
    if (tmp > 0)
      tol = (tol < tmp) ? tol : tmp;        
  }
#ifdef MATLAB_MEX_FILE
  if (0) {
    char_T err_msg[255];
    sprintf(err_msg, "\n");
    mexPrintf(err_msg);
  }
#endif
  *hit_base = offsetMin + sampleTime;
  *hit_base = sampleTime;
  *tolerance = tol / 100;
}

/*
 * mdlOutputs - computes the outputs of the S-Function
 */

static void mdlOutputs(real_T *y, const real_T *x, const real_T *u, SimStruct *S, int_T tid)
{
  int_T dividerSize = mxGetN(DIVIDER_EACH) * mxGetM(DIVIDER_EACH);
  real_T *hit_base      = ssGetRWork(S);
  real_T *next_hit      = ssGetRWork(S) + 1;    
  real_T *last_value    = ssGetRWork(S) + dividerSize + 1;
  real_T *increment     = ssGetRWork(S) + dividerSize * 2 + 1;
  real_T *adj_offset    = ssGetRWork(S) + dividerSize * 3 + 1;
  real_T *tolerance     = ssGetRWork(S) + dividerSize * 4 + 1;
  int_T    *reverse = ssGetIWork(S);
  
  real_T time_clock, tol;
  int_T i;
  
  tol = *tolerance;
  
  time_clock = ssGetT(S) + tol;
  for (i = 0; i < dividerSize; i++) {
    if (time_clock >= next_hit[i]) {
      int_T    num;
      real_T sampleTime;
      
      sampleTime = mxGetPr(SAMPLE_TIME)[0];        
      num = (int_T)((time_clock - *hit_base - adj_offset[i] - sampleTime) / increment[i]);
      num = num%2;
      if (num)
	last_value[i] = 1.;
      else
	last_value[i] = 0.;
#ifdef MATLAB_MEX_FILE
      if (0) {
	char_T err_msg[255];
	sprintf(err_msg, "reverse[%d]=%d; last_value=%d; \n", i, reverse[i], (int_T)last_value[i]);
	mexPrintf(err_msg);
      }
#endif
      if (reverse[i])
	last_value[i] = ((int_T)last_value[i] + 1) % 2;
#ifdef MATLAB_MEX_FILE
      if (0) {
	char_T err_msg[255];
	sprintf(err_msg, "new_last_value=%d;\n ", (int_T)last_value[i]);
	mexPrintf(err_msg);
      }
#endif
      next_hit[i] = next_hit[i] + increment[i];
    }
    y[i] = last_value[i];
  }
  
  /*    sprintf(err_msg, "\n ");
	mexPrintf(err_msg);
	
	for (i = 0; i < dividerSize; i++) {
	sprintf(err_msg, "output_y[%d]= %f, \", i, y[i]);
	mexPrintf(err_msg);
	}
	*/
  /* adjust the "current hit" every sample cycle.    */
  if (time_clock > *hit_base){
    real_T sampleTime;
    sampleTime = mxGetPr(SAMPLE_TIME)[0];        
    for (i = 0; i < dividerSize; i++) {
      if (time_clock > mxGetPr(OFFSET_EACH)[i]) {
	
	if (adj_offset[i] <= 0) {
	  next_hit[i] = *hit_base + increment[i];
	} else {
	  next_hit[i] = *hit_base + adj_offset[i];
	}
      }
    }
    *hit_base = *hit_base +sampleTime;        
  }    
}

/*
 * mdlUpdate - computes the discrete states of the S-Function
 */

static void mdlUpdate(real_T *x, const real_T *u, SimStruct *S, int_T tid)
{
}

/*
 * mdlDerivatives - computes the derivatives of the S-Function
 */

static void mdlDerivatives(real_T *dx, const real_T *x, const real_T *u, SimStruct *S, int_T tid)
{
}

/*
 * mdlTerminate - called at termination of model execution.
 */

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 + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一区二区三区四区av| 色婷婷国产精品综合在线观看| 免费三级欧美电影| 精品无人码麻豆乱码1区2区| 国产成a人无v码亚洲福利| 亚洲午夜一二三区视频| 男女性色大片免费观看一区二区 | 欧美v国产在线一区二区三区| 欧美一区二区在线免费播放| 欧美欧美欧美欧美| 精品剧情v国产在线观看在线| 2020国产精品自拍| 亚洲欧美日韩国产成人精品影院 | 美国十次了思思久久精品导航| 天堂精品中文字幕在线| 国产精品资源站在线| 成人一区二区三区在线观看 | 成人高清在线视频| 欧美视频完全免费看| 日韩一区二区不卡| 亚洲视频一区二区在线观看| 美国毛片一区二区三区| 91在线精品一区二区三区| 制服丝袜在线91| 欧美国产禁国产网站cc| 日韩精品电影在线| 91丨porny丨在线| 日韩免费在线观看| 亚洲国产成人porn| 99精品欧美一区二区蜜桃免费| 欧美精品123区| 亚洲美女一区二区三区| 免费精品99久久国产综合精品| 91看片淫黄大片一级在线观看| 久久久99久久| 亚洲sss视频在线视频| 成人av先锋影音| 日韩欧美一区在线| 亚洲国产成人tv| 99久久精品一区| 久久精品亚洲一区二区三区浴池 | 蜜乳av一区二区| 欧洲人成人精品| 国产精品理伦片| 福利视频网站一区二区三区| 欧美一三区三区四区免费在线看| 亚洲免费在线播放| 成人精品免费看| 久久精品网站免费观看| 久久精品国产77777蜜臀| 白白色 亚洲乱淫| 国产片一区二区| 丁香天五香天堂综合| 欧美精品一区二区三区四区| 亚瑟在线精品视频| 欧美午夜电影网| 亚洲高清视频在线| 色综合久久久久综合体| 亚洲视频在线观看三级| 99久久99久久精品国产片果冻| 久久日韩精品一区二区五区| 黄色日韩网站视频| 精品三级av在线| 久久国产日韩欧美精品| 亚洲精品一区二区三区精华液| 男女性色大片免费观看一区二区| 欧美一二三四在线| 免费观看日韩av| 久久综合九色综合欧美就去吻| 国产乱人伦偷精品视频免下载| 精品成人一区二区| 国产麻豆视频一区二区| 国产目拍亚洲精品99久久精品 | 欧美日韩中文国产| 午夜精品久久久久久久99樱桃| 欧美日韩免费高清一区色橹橹 | 国产精品一品视频| 国产精品乱人伦一区二区| 国产真实精品久久二三区| 精品免费日韩av| 懂色中文一区二区在线播放| 国产精品久久毛片av大全日韩| 91视频观看免费| 五月天激情综合网| 久久人人爽爽爽人久久久| 韩国成人在线视频| 一区在线观看视频| 欧美精品色一区二区三区| 男人的j进女人的j一区| 久久日韩粉嫩一区二区三区| 91视频91自| 久久超级碰视频| 中文一区在线播放| 欧美日韩情趣电影| 国产美女精品一区二区三区| 久久精品综合网| 性久久久久久久| 国产欧美日韩在线观看| 精品久久人人做人人爽| 欧美久久一二三四区| 色噜噜狠狠成人网p站| 成人少妇影院yyyy| 国产精品99久久久| 精品亚洲欧美一区| 久久99久久99| 裸体一区二区三区| 全国精品久久少妇| 免费在线观看精品| 日本v片在线高清不卡在线观看| 亚洲在线一区二区三区| 一区二区三区成人| 亚洲精品欧美专区| 亚洲欧美一区二区三区国产精品| 亚洲欧美综合在线精品| 国产精品视频看| 中文字幕亚洲成人| 亚洲精品综合在线| 久久久亚洲精华液精华液精华液| 日本不卡的三区四区五区| 日韩欧美区一区二| 在线播放日韩导航| 在线播放91灌醉迷j高跟美女 | 久久只精品国产| 久久久综合激的五月天| 精品国精品国产尤物美女| 久久综合久色欧美综合狠狠| 久久久一区二区三区捆绑**| 国产蜜臀av在线一区二区三区| 国产日韩欧美麻豆| 国产精品国产三级国产aⅴ原创 | 伊人色综合久久天天| 一区二区三区四区不卡视频| 亚洲成a人v欧美综合天堂| 日韩一区精品字幕| 激情五月播播久久久精品| 国产精品一区二区在线观看网站 | 91精品国产高清一区二区三区蜜臀| 欧美一区日韩一区| 久久久噜噜噜久久人人看| 国产亚洲一二三区| 亚洲色欲色欲www| 天天综合色天天| 狠狠狠色丁香婷婷综合激情| 国产成人免费在线视频| 色视频一区二区| 欧美人狂配大交3d怪物一区| 日韩美一区二区三区| 国产精品无遮挡| 日韩情涩欧美日韩视频| 日韩久久久精品| 成人自拍视频在线观看| 一本一道波多野结衣一区二区| 欧美久久一区二区| 国产欧美视频在线观看| 亚洲一区电影777| 韩国毛片一区二区三区| 99re成人精品视频| 日韩一区二区视频| 亚洲欧美另类久久久精品2019| 日韩精品电影在线观看| 成av人片一区二区| 日韩一区二区三区在线观看 | 久久99精品国产| 99精品国产一区二区三区不卡| 欧美日韩国产色站一区二区三区| 国产午夜精品久久| 日韩av电影免费观看高清完整版| 成人午夜免费电影| 欧美丰满美乳xxx高潮www| 国产精品污污网站在线观看| 美女一区二区久久| 91麻豆国产香蕉久久精品| 精品国产青草久久久久福利| 亚洲第一在线综合网站| 成人激情开心网| 精品91自产拍在线观看一区| 视频一区二区三区在线| 色综合色狠狠综合色| 久久精品人人做人人爽人人 | 一区二区三区 在线观看视频| 狠狠v欧美v日韩v亚洲ⅴ| 欧美高清一级片在线| 亚洲精品videosex极品| 成人小视频在线| 26uuu精品一区二区三区四区在线 26uuu精品一区二区在线观看 | 国产精品99久久久久久久vr| 91精品婷婷国产综合久久性色| 亚洲日本在线视频观看| 国产成人精品免费一区二区| 日韩欧美国产一区在线观看| 亚洲综合在线电影| 91丨porny丨国产| 国产精品久久看| 国产乱人伦精品一区二区在线观看| 亚洲综合激情小说| 欧美国产一区在线| 亚洲欧美福利一区二区| 成人激情黄色小说| 国产女人aaa级久久久级| 韩国午夜理伦三级不卡影院|