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

? 歡迎來(lái)到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? homopuls.c

?? 3G源碼Mfiles有很詳實(shí)的內(nèi)容哦適合3g初學(xué)者
?? C
字號(hào):
/* $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



?? 快捷鍵說(shuō)明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號(hào) Ctrl + =
減小字號(hào) Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
成人福利视频网站| 国产精品久久久久久亚洲毛片| 在线观看网站黄不卡| www.亚洲激情.com| 粉嫩aⅴ一区二区三区四区 | 日韩中文字幕区一区有砖一区 | 国产乱一区二区| 狠狠v欧美v日韩v亚洲ⅴ| 久久aⅴ国产欧美74aaa| 精品一区二区三区视频| 久久99精品视频| 激情国产一区二区| 国产福利91精品一区| 国产成人免费在线视频| 成人性生交大合| 91在线观看美女| 欧美性猛交xxxx黑人交| 欧美精品第一页| 日韩午夜在线播放| 久久久久国产精品人| 国产精品污污网站在线观看| 中文字幕在线观看一区二区| 亚洲精品第1页| 亚洲午夜久久久久久久久电影院 | 美脚の诱脚舐め脚责91| 韩国三级在线一区| 国产精品一色哟哟哟| 成人动漫一区二区| 欧美亚洲综合网| 91麻豆精品国产91| 2020国产精品| 一色屋精品亚洲香蕉网站| 亚洲一区二区av电影| 麻豆精品一二三| 成人黄色电影在线 | 2欧美一区二区三区在线观看视频| 精品国产乱码久久久久久图片| 欧美激情在线一区二区| 日韩久久一区二区| 偷拍亚洲欧洲综合| 狠狠色丁香久久婷婷综| 91看片淫黄大片一级| 777色狠狠一区二区三区| 久久亚洲二区三区| 亚洲黄色av一区| 老司机午夜精品99久久| 成人福利视频网站| 这里只有精品电影| 中文字幕日韩欧美一区二区三区| 亚洲观看高清完整版在线观看| 国产最新精品精品你懂的| 99久久精品国产精品久久| 欧美一区二区三区婷婷月色| 国产精品色婷婷| 日韩精品色哟哟| jiyouzz国产精品久久| 欧美高清视频一二三区 | 欧美日韩在线直播| 国产日韩v精品一区二区| 亚洲一区二区在线观看视频| 国产一区不卡视频| 在线一区二区三区四区五区| 久久人人爽人人爽| 亚洲成在人线免费| 成人18视频日本| 欧美tk—视频vk| 亚洲永久精品大片| 懂色av一区二区三区免费看| 91精品国产乱| 亚洲精品自拍动漫在线| 国产精品自拍三区| 欧美一级高清片| 亚洲国产美女搞黄色| 丁香桃色午夜亚洲一区二区三区| 91精品国产高清一区二区三区蜜臀 | 欧美日韩电影在线| 亚洲情趣在线观看| 精品在线免费观看| 91麻豆精品国产91久久久 | 盗摄精品av一区二区三区| 日韩欧美成人一区| 亚洲国产精品一区二区www在线| 高清免费成人av| 久久在线观看免费| 麻豆成人91精品二区三区| 欧美日韩精品综合在线| 亚洲欧洲制服丝袜| 成人app在线| 国产精品色哟哟| 丁香天五香天堂综合| 久久久www成人免费毛片麻豆| 久久精品国产免费| 欧美日本在线观看| 午夜视频久久久久久| 欧美色精品在线视频| 一区二区在线观看视频在线观看| 成人国产电影网| 中文字幕乱码亚洲精品一区| 国产精品一区二区久久不卡| 欧美精品一区视频| 国内久久精品视频| 2023国产精华国产精品| 黄色日韩三级电影| 久久亚洲精精品中文字幕早川悠里| 久久电影网站中文字幕| 欧美电视剧在线观看完整版| 久久99国产精品免费| 欧美草草影院在线视频| 久久国产精品99久久久久久老狼| 日韩欧美www| 韩国精品主播一区二区在线观看 | 久久精品一区二区三区四区| 国产精品亚洲第一区在线暖暖韩国 | 日韩一本二本av| 另类专区欧美蜜桃臀第一页| 日韩一级完整毛片| 久久国产精品区| 国产偷国产偷精品高清尤物| av中文字幕一区| 玉足女爽爽91| 这里是久久伊人| 国产美女精品人人做人人爽 | 国产精品一区二区久久不卡| 日本一区二区三区四区在线视频 | 精品视频999| 蜜桃一区二区三区在线观看| 久久久久国产精品麻豆ai换脸 | 日韩亚洲国产中文字幕欧美| 精品一区二区三区久久久| 2023国产一二三区日本精品2022| 国产不卡在线播放| 亚洲男女一区二区三区| 欧美日韩国产免费一区二区| 精品一区二区三区不卡| 亚洲国产高清aⅴ视频| 91麻豆国产在线观看| 日韩精品乱码免费| 国产亚洲一区二区三区在线观看| 99国产精品久| 午夜不卡av在线| 国产亚洲综合色| 欧美亚洲禁片免费| 国产一区二区三区在线观看精品| 国产精品成人午夜| 欧美伦理视频网站| 国产黄色精品视频| 亚洲国产wwwccc36天堂| 久久在线观看免费| 欧美影院精品一区| 国产精品99久久久| 亚洲午夜免费视频| 欧美国产在线观看| 69av一区二区三区| 成人h动漫精品| 免费看日韩精品| 亚洲视频每日更新| 精品久久人人做人人爽| 99re这里只有精品首页| 久久成人免费电影| 亚洲精品成人悠悠色影视| 日韩免费看的电影| 色乱码一区二区三区88| 国产一区二区三区精品欧美日韩一区二区三区| 国产精品美女久久福利网站| 日韩一区二区免费在线电影| 99精品视频在线观看| 看国产成人h片视频| 亚洲激情av在线| 国产精品系列在线| 精品裸体舞一区二区三区| 日本韩国欧美一区| 成人免费毛片嘿嘿连载视频| 日本欧美加勒比视频| 亚洲欧美日韩国产成人精品影院| 精品国产乱码久久久久久牛牛| 在线观看不卡一区| av中文字幕不卡| 国产一区二区精品久久99| 丝袜亚洲精品中文字幕一区| 亚洲人成小说网站色在线| 国产三级精品在线| 日韩免费一区二区三区在线播放| 欧美调教femdomvk| 色综合久久六月婷婷中文字幕| 国产精品99久久久久| 九九九精品视频| 日本少妇一区二区| 亚洲一本大道在线| 亚洲视频在线一区观看| 国产三级精品三级| 久久久九九九九| 精品粉嫩超白一线天av| 欧美一区中文字幕| 欧美巨大另类极品videosbest | 一区二区三区久久| 亚洲欧美在线观看| 国产精品国产成人国产三级| 亚洲国产成人在线| 欧美国产激情一区二区三区蜜月 | 激情小说亚洲一区|