资源简介
matlab重现 正弦信号 重复控制器 简单的代码
代码片段和文件信息
#define S_FUNCTION_NAME test2
#define S_FUNCTION_LEVEL 2
/*
* Need to include simstruc.h for the definition of the SimStruct and
* its associated macro definitions.
*/
#include “simstruc.h“
#include
/*====================*
* S-function methods *
*====================*/
/* Function: mdlInitializeSizes ===============================================
* Abstract:
* The sizes information is used by Simulink to determine the S-function
* block‘s characteristics (number of inputs outputs states etc.).
*/
static void mdlInitializeSizes(SimStruct *S)
{
/* See sfuntmpl_doc.c for more details on the macros below */
ssSetNumSFcnParams(S 0); /* Number of expected parameters */
if (ssGetNumSFcnParams(S) != ssGetSFcnParamsCount(S)) {
/* Return if number of expected != number of actual parameters */
return;
}
ssSetNumContStates(S 0);
ssSetNumDiscStates(S 0);
if (!ssSetNumInputPorts(S 1)) return;
ssSetInputPortWidth(S 0 1);
ssSetInputPortRequiredContiguous(S 0 true); /*direct input signal access*/
/*
* Set direct feedthrough flag (1=yes 0=no).
* A port has direct feedthrough if the input is used in either
* the mdlOutputs or mdlGetTimeOfNextVarHit functions.
* See matlabroot/simulink/src/sfuntmpl_directfeed.txt.
*/
ssSetInputPortDirectFeedThrough(S 0 1);
if (!ssSetNumOutputPorts(S 1)) return;
ssSetOutputPortWidth(S 0 4);
ssSetNumSampleTimes(S 1);
ssSetNumRWork(S 0);
ssSetNumIWork(S 0);
ssSetNumPWork(S 0);
ssSetNumModes(S 0);
ssSetNumNonsampledZCs(S 0);
ssSetOptions(S SS_OPTION_EXCEPTION_FREE_CODE);
}
/* Function: mdlInitializeSampleTimes =========================================
* Abstract:
* This function is used to specify the sample time(s) for your
* S-function. You must register the same number of sample times as
* specified in ssSetNumSampleTimes.
*/
static void mdlInitializeSampleTimes(SimStruct *S)
{
ssSetSampleTime(S 0 52e-6);
ssSetOffsetTime(S 0 0.0);
}
#define MDL_INITIALIZE_CONDITIONS /* Change to #undef to remove function */
#if defined(MDL_INITIALIZE_CONDITIONS)
/* Function: mdlInitializeConditions ========================================
* Abstract:
* In this function you should initialize the continuous and discrete
* states for your S-function block. The initial states are placed
* in the state vector ssGetContStates(S) or ssGetRealDiscStates(S).
* You can also perform any other initialization activities that your
* S-function may require. Note this routine will be called at the
* start of simulation and if it is present in an enabled subsystem
* configured to reset states it will be call when the enabled subsystem
* restarts execution to reset the states.
*/
static void mdlInitializeC
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 7622 2020-09-21 13:26 test2.asv
文件 11022 2020-09-21 13:26 test2.c
文件 21504 2020-09-21 13:26 test2.mexw32
文件 253 2020-09-21 13:26 Unti
文件 248 2020-09-21 13:26 Unti
文件 39939 2020-09-21 13:26 unti
评论
共有 条评论