资源简介
自抗扰控制,最速跟踪微分器Matlab仿真,用S函数写的,参数已经调好,MATLAB configure得设置为fix step ,采样时间设置为1e-3(与步长h相同即可)。
代码片段和文件信息
/*
* sfuntmpl_basic.c: Basic ‘C‘ template for a level 2 S-function.
*
* -------------------------------------------------------------------------
* | See matlabroot/simulink/src/sfuntmpl_doc.c for a more detailed template |
* -------------------------------------------------------------------------
*
* Copyright 1990-2002 The MathWorks Inc.
* $Revision: 1.27 $
*/
/*
* You must specify the S_FUNCTION_NAME as the name of your S-function
* (i.e. replace sfuntmpl_basic with the name of your S-function).
*/
#define S_FUNCTION_NAME ADRC_TD
#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
/* Error handling
* --------------
*
* You should use the following technique to report errors encountered within
* an S-function:
*
* ssSetErrorStatus(S“Error encountered due to ...“);
* return;
*
* Note that the 2nd argument to ssSetErrorStatus must be persistent memory.
* It cannot be a local variable. For example the following will cause
* unpredictable errors:
*
* mdlOutputs()
* {
* char msg[256]; {ILLEGAL: to fix use “static char msg[256];“}
* sprintf(msg“Error due to %s“ string);
* ssSetErrorStatus(Smsg);
* return;
* }
*
* See matlabroot/simulink/src/sfuntmpl_doc.c for more details.
*/
/*====================*
* 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; //input r h x0 N
ssSetInputPortWidth(S 0 4);
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; //output x1 x2
ssSetOutputPortWidth(S 0 2);
ssSetNumSampleTimes(S 1);
ssSetNumRWork(S 0);
ssSetNumIWork(S 0);
ssSetNumPWork(S 0);
ssSetNumModes(S 0);
ssSetNumNonsampledZCs(S 0);
ssSetOptions(S1);
}
/* Function: mdlInitiali 属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 8055 2019-07-01 20:17 ADRC_TD.c
文件 35328 2019-06-18 19:44 ADRC_TD.mexw64
文件 45114 2019-06-27 15:10 TD_TEST.mdl
相关资源
- 串行级联cpm系统MATLAB仿真
- matlab_OFDM调制解调(来自剑桥大学)
- Matlab路面裂缝识别69319
- 高灵敏度GPS接收机MATLAB仿真,附捕获
- 基于MATLAB的质点弹道计算与外弹道优
- 阵列天线的matlab仿真
- MATLAB 经典程序源代码大全
- MATLAB小波软阈值去噪代码33473
- 天线阵的波束形成在MATLAB仿真程序及
- 非线性SVM算法-matlab实现
- 《MATLAB 智能算法超级学习手册》-程序
- 组合导航matlab程序
- 读取txt文件内容matlab代码实现
- Matlab实现基于相关的模板匹配程序
- matlab优化工具箱讲解
- 基于MATLAB的快速傅里叶变换
- 光纤传输中的分布傅立叶算法matlab实
- 基于matlab的图像处理源程序
- matlab 椭圆拟合程序
- 算术编码解码matlab源代码
- optical_flow 光流法 matlab 实现程序
- 引导图像滤波器 Matlab实现
- 分形几何中一些经典图形的Matlab画法
- OFDM系统MATLAB仿真代码
- SVM工具箱(matlab中运行)
- 图像小波变换MatLab源代码
- LU分解的MATLAB实现
- 冈萨雷斯数字图像处理matlab版(第三
- 替代数据法的matlab程序
- 用matlab实现的多站定位系统性能仿真
川公网安备 51152502000135号
评论
共有 条评论