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

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

?? regdown.c

?? 3G源碼Mfiles有很詳實的內容哦適合3g初學者
?? C
字號:
/* $Revision: 1.21 $ */
/*
 * REGDOWN   A Simulink register down block
 *
 * Syntax:  [sys, x0] = regdown(t, x, u, flag, OutputIndex, Increament, trigThreshold, cycl_flag)
 *      This block outputs a vector with the initial index given in OutputIndex.
 *      The increament of the index is given in Increament. This block has three
 *      input veriables. The first is a vector providing the register signals.
 *      The second is a clock signal to trigger the refreshment of the register in
 *      in this block. The third is a trigger signal for the output refreshment.
 *      The block uses the rising edge of both second and third input pulse
 *      to trigger the action. At the rising edge of the third signal, a positive
 *      signal at the third inport would cause the output refreshemnt.
 *
 * Wes Wang 8/23, 1994
 *
 * Copyright 1996-2001 The MathWorks, Inc.
 */

#define S_FUNCTION_NAME regdown

#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"

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

#define NUM_ARGS        4
#define OUTPUT_INDEX   ssGetArg(S,0)
#define INCREAMENT     ssGetArg(S,1)
#define TRIG_THRSHLD   ssGetArg(S,2)
#define CYCLIC_FLAG    ssGetArg(S,3)

/*
 * 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 void mdlInitializeSizes(SimStruct *S)
{
  int_T num_output_idx, num_increament;
    
  /*
   * Set-up size information.
   */ 

  if (ssGetNumArgs(S) == NUM_ARGS) {
    /* check the dimension for OUTPUT_INDEX and INCREAMNET */
    num_output_idx = mxGetN(OUTPUT_INDEX) * mxGetM(OUTPUT_INDEX);
    num_increament  = mxGetN(INCREAMENT)   * mxGetM(INCREAMENT);
    if (num_output_idx <= 0) {
#ifdef MATLAB_MEX_FILE
      mexErrMsgTxt("OutputIndex cannot be a empty vector.");
#endif        
    }
    if (num_output_idx != num_increament) {
      if (num_increament != 1) {
#ifdef MATLAB_MEX_FILE
         mexErrMsgTxt("The vector size for OutputIndex and Increment must be the same.");
#endif
      }
    }
    
    if ((mxGetN(TRIG_THRSHLD)*mxGetM(TRIG_THRSHLD) != 1)) {
#ifdef MATLAB_MEX_FILE
      mexErrMsgTxt("The threshold must be a scalar.");
#endif
    } 
       
    ssSetNumContStates(    S, 0);
    ssSetNumDiscStates(    S, 0);
    ssSetNumInputs(        S, -1);
    ssSetNumOutputs(       S, 1 + num_output_idx);
    ssSetDirectFeedThrough(S, 1);
    ssSetNumInputArgs(     S, NUM_ARGS);
    ssSetNumSampleTimes(   S, 1);
    ssSetNumRWork(         S, -1);
    /* the buffer size is input_vector + trig_in + trig_out
     * R vector is assigned as buffer, lastTime2, lastTime3
     */
    ssSetNumIWork(         S, 2 + 2 * num_output_idx);
    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)
{
     /*
     * Note, blocks that are continuous in nature should have a single
     * sample time of 0.0.
     */

    ssSetSampleTimeEvent(S, 0, INHERITED_SAMPLE_TIME);
    ssSetOffsetTimeEvent(S, 0, FIXED_IN_MINOR_STEP_OFFSET);
}

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

static void mdlInitializeConditions(real_T *x0, SimStruct *S)
{
    int_T num_output_idx   = ssGetNumOutputs(S) - 1;
    real_T *regi         = ssGetRWork(S);

    int_T *lastTrig2       = ssGetIWork(S);
    int_T *lastTrig3       = ssGetIWork(S) + 1;
    int_T *outputIndex     = ssGetIWork(S) + 2; 

    int_T *increament      = ssGetIWork(S) + num_output_idx + 2;

    int_T num_increament   = mxGetN(INCREAMENT) * mxGetM(INCREAMENT);

    int_T regiSize         = ssGetNumInputs(S) - 2;

    int_T i;

    /* 
     * Initialize the buffer to all zeros, we could allow this to
     * be an additional paramter.
     */
    
    for (i = 0; i < regiSize; i++)
        *regi++ = 0.;
    /*
     * Initialize the current buffer position, buffer start, and output index
     */
    
    for (i = 0; i < num_output_idx; i++) {
        if (mxGetPr(OUTPUT_INDEX)[i] < 0) {
#ifdef MATLAB_MEX_FILE
             mexErrMsgTxt("Output Index must be positive integers.");
#endif
                }
        *outputIndex++ = (int_T) mxGetPr(OUTPUT_INDEX)[i];
        if (num_increament == 1) {
            *increament++ = (int_T)mxGetPr(INCREAMENT)[0];
                } else {
            *increament++ = (int_T)mxGetPr(INCREAMENT)[i];
        }
    }
    *lastTrig2 = 0;
    *lastTrig3 = 0;
    if (regiSize >= 0) {
        real_T *lastTime2    = ssGetRWork(S) + regiSize;
        real_T *lastTime3    = ssGetRWork(S) + regiSize + 1;
        *lastTime2 = -1.0;
        *lastTime3 = -1.0;
    }
}

/*
 * 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 num_output_idx   = ssGetNumOutputs(S) - 1;
    real_T *regi         = ssGetRWork(S);
    real_T  trigThreshold   = mxGetPr(TRIG_THRSHLD)[0];
    
    int_T *lastTrig2       = ssGetIWork(S);
    int_T *lastTrig3       = ssGetIWork(S) + 1;
    int_T *outputIndex     = ssGetIWork(S) + 2; 

    int_T *increament      = ssGetIWork(S)+ num_output_idx + 2;

    int_T regiSize         = ssGetNumInputs(S) - 2;

    real_T *lastTime2    = ssGetRWork(S) + regiSize;
    real_T *lastTime3    = ssGetRWork(S) + regiSize + 1;
    real_T currentTime   = ssGetT(S);
    
    int_T cycl_flag   = (int_T)mxGetPr(CYCLIC_FLAG)[0];
    
    int_T i, modulo_idx;
    if ((u[regiSize] >= trigThreshold) & (*lastTrig2 == 0)) {
      for (i = 0; i < regiSize; i++)
        regi[i] = u[i];
      /* refresh output index */
      for (i = 0; i < num_output_idx; i++)
        outputIndex[i] = (int_T) mxGetPr(OUTPUT_INDEX)[i];
      /* reset trigger flag */
      *lastTrig2 = 1;
      y[num_output_idx] = 1;
      *lastTime2 = currentTime;
    } else {
      if (u[regiSize] >= trigThreshold) {
        if (currentTime > 0) {
          if ((currentTime - *lastTime2) / currentTime < 0.00000001) {
            /* re-refresh the buffer, use the most recent one */
            for (i = 0; i < regiSize; i++)
              regi[i] = u[i];
            /* verify whether the output needs to refresh */
            if ((u[regiSize + 1] >= trigThreshold) && ((currentTime - *lastTime3) / currentTime < 0.00000001)) {
              int_T backIndex;
                
              for (i = 0; i < num_output_idx; i++) {
                backIndex = outputIndex[i] - increament[i];

                if (cycl_flag > 0) {
                  if (backIndex >= 0)
                    backIndex %= regiSize;
                  else 
                    backIndex = (regiSize - ((-backIndex) % regiSize)) % regiSize;
                  y[i] = regi[backIndex];
                } else {
                  if ((backIndex < regiSize) & (backIndex >= 0))
                    y[i] = regi[backIndex];
                  else
                    y[i] = 0.0;
                }
              }
            }
          }
        }
      } else if (*lastTrig2 == 1) {
        if (u[regiSize] < trigThreshold) {
          *lastTrig2 = 0;
          y[num_output_idx] = 0.0;
        }
      }
    }
    if ((u[regiSize + 1] >= trigThreshold) & (*lastTrig3 == 0)) {
      for (i = 0; i < num_output_idx; i++) {
        /* refresh output */
        if (cycl_flag > 0) {
          modulo_idx = outputIndex[i];
          if (modulo_idx >= 0)
            modulo_idx %= regiSize;
          else 
            modulo_idx = (regiSize - ((-modulo_idx) % regiSize)) % regiSize;
          y[i] = regi[modulo_idx];
        } else {
          if ((outputIndex[i] < regiSize) & (outputIndex[i] >= 0))
            y[i] = regi[outputIndex[i]];
          else
            y[i] = 0.0;
        }

        /* refresh output index */                
        outputIndex[i] += increament[i];
      }
      *lastTrig3 = 1;
      *lastTime3 = currentTime;
    } else {
      if (*lastTrig3 == 1) {
        if (u[regiSize+1] < trigThreshold)
          *lastTrig3 = 0;
      }
      if (ssGetT(S) <= 0.0) {
        for (i = 0; i < num_output_idx; i++)
          y[i] = 0.0;         
      } 
    }
}

/*
 * 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一区二区三区免费野_久草精品视频
婷婷久久综合九色国产成人| 国产一区二区三区视频在线播放| 亚洲va韩国va欧美va精品| 韩国精品在线观看| 欧美日精品一区视频| 中文字幕日韩精品一区| 国产一区二区不卡| 91精品国产综合久久蜜臀| 亚洲免费色视频| 99r精品视频| 久久久精品国产免费观看同学| 五月综合激情婷婷六月色窝| 91免费在线视频观看| 国产精品色眯眯| 国产成人一级电影| 欧美精品一区二区蜜臀亚洲| 丝袜a∨在线一区二区三区不卡| 99久久精品国产一区二区三区| 久久精品亚洲一区二区三区浴池| 日本人妖一区二区| 欧美高清性hdvideosex| 亚洲狠狠爱一区二区三区| 一本色道久久加勒比精品 | 福利一区福利二区| 欧美电影免费观看完整版| 美女网站色91| 日韩一区二区三区四区| 视频在线观看一区| 91精品国产色综合久久ai换脸 | 久久国产免费看| 欧美一二三区精品| 久久精品国产亚洲aⅴ| 欧美电视剧在线观看完整版| 国产最新精品免费| 久久久久久久久99精品| 国产sm精品调教视频网站| 国产精品视频免费| 99久久婷婷国产| 一区二区三区在线观看国产| 色94色欧美sute亚洲线路一久| 亚洲精品自拍动漫在线| 欧美日韩亚洲综合一区二区三区| 亚洲无线码一区二区三区| 欧美人妖巨大在线| 麻豆一区二区三| 久久美女高清视频| 97se亚洲国产综合自在线观| 亚洲免费av观看| 在线不卡a资源高清| 国产一区三区三区| 国产精品免费视频网站| 欧美午夜理伦三级在线观看| 日本va欧美va欧美va精品| 日韩欧美国产三级电影视频| 国产成人超碰人人澡人人澡| 亚洲人成人一区二区在线观看 | 久久久久久久av麻豆果冻| 成人精品电影在线观看| 亚洲成人精品影院| 久久精品人人做人人爽97| 91麻豆swag| 精品一区二区三区日韩| 一区精品在线播放| 制服丝袜国产精品| 粉嫩av一区二区三区在线播放| 日韩一区在线免费观看| 欧美体内she精高潮| 精品一区二区精品| 亚洲欧洲国产日韩| 日韩一区二区三区电影在线观看 | 日韩精品一二三四| 国产嫩草影院久久久久| 欧美日韩国产综合视频在线观看 | 亚洲色图另类专区| 日韩一区二区免费在线电影| 粉嫩在线一区二区三区视频| 日本大胆欧美人术艺术动态| 久久久久久久精| 在线欧美小视频| 国产激情视频一区二区在线观看| 亚洲色图另类专区| 国产调教视频一区| 欧美男同性恋视频网站| av高清久久久| 国产一区在线观看麻豆| 日韩电影网1区2区| 一区二区三区四区激情| 欧美国产综合色视频| 日韩一级黄色片| 欧美日韩一区二区欧美激情 | 久草在线在线精品观看| 亚洲一二三区视频在线观看| 日韩女同互慰一区二区| 在线精品国精品国产尤物884a| 国产成人在线观看免费网站| 日本不卡在线视频| 午夜激情综合网| 亚洲欧美日韩一区二区三区在线观看| 欧美电影免费提供在线观看| 欧美日本韩国一区二区三区视频 | 粉嫩一区二区三区性色av| 久色婷婷小香蕉久久| 亚洲大片在线观看| 亚洲午夜一区二区三区| 亚洲黄一区二区三区| 亚洲精品视频在线观看免费| 一区二区中文视频| 亚洲青青青在线视频| 国产精品高潮久久久久无| 国产精品私人影院| 国产精品久久久久一区| 国产精品免费观看视频| 国产欧美精品国产国产专区| 欧美激情资源网| 国产婷婷色一区二区三区四区 | 日韩欧美一区二区不卡| 日韩精品在线一区| 欧美第一区第二区| 精品国产伦一区二区三区免费| 精品理论电影在线观看| 精品成人一区二区三区| 久久久蜜桃精品| 国产精品美女一区二区| 国产精品理论在线观看| 亚洲日本护士毛茸茸| 一区二区三区欧美久久| 亚洲国产精品天堂| 日本不卡1234视频| 成人午夜电影久久影院| 不卡的av电影| 欧美亚洲一区二区在线| 欧美福利视频一区| 亚洲精品一区二区三区蜜桃下载 | 欧美xxxxxxxx| 国产精品国产馆在线真实露脸| 亚洲欧美日韩一区| 性久久久久久久久久久久| 久久精品国内一区二区三区| 高清不卡一二三区| 欧美亚洲国产一卡| 精品剧情在线观看| 亚洲视频香蕉人妖| 日本成人在线看| 丁香天五香天堂综合| 91麻豆国产香蕉久久精品| 欧美一区二区三区白人| 日本一区二区视频在线| 亚洲一区二区欧美| 国产精品99久久久久久久vr| 91美女在线看| 精品久久久久久亚洲综合网| 综合欧美一区二区三区| 精品亚洲免费视频| 欧美在线视频全部完| 久久久久国产精品厨房| 亚洲精品国产品国语在线app| 黄网站免费久久| 在线看不卡av| 国产人久久人人人人爽| 亚洲成a人v欧美综合天堂下载| 国产精品资源站在线| 欧美日韩精品欧美日韩精品一 | 日韩和欧美一区二区三区| 成人一区二区在线观看| 欧美美女bb生活片| 亚洲美女屁股眼交3| 国产精品一区二区三区网站| 欧美日韩精品欧美日韩精品一| 中文字幕一区二区5566日韩| 免费欧美在线视频| 欧美在线三级电影| 欧美国产精品v| 激情五月婷婷综合| 6080yy午夜一二三区久久| 亚洲欧洲韩国日本视频| 国产91露脸合集magnet| 欧美mv日韩mv国产| 青青草精品视频| 欧美在线免费观看亚洲| 亚洲色图自拍偷拍美腿丝袜制服诱惑麻豆 | 免费在线一区观看| 欧美日韩在线直播| 亚洲一区二区精品3399| 一本色道久久综合亚洲精品按摩| 国产午夜精品美女毛片视频| 青草av.久久免费一区| 欧美少妇bbb| 亚洲国产一区二区视频| 在线观看日产精品| 亚洲欧美怡红院| 91美女片黄在线| 亚洲女女做受ⅹxx高潮| 91行情网站电视在线观看高清版| 中文字幕综合网| 色爱区综合激月婷婷| 中文字幕一区二区三区在线不卡 | 亚洲一区二三区| 色婷婷综合久久久久中文一区二区| 国产精品少妇自拍| 9久草视频在线视频精品|