×

《MATLAB的S-Function编写指导》[1]

消耗积分:1 | 格式:pdf | 大小:2388KB | 2012-05-21

分享资料个

恒润科技 一本很实用很详细的S-FUNCTION函数编写的工具书! S-FUNCTION 概述................................................................................................................................... 1 什么是S-FUNCTION............................................................................................................................... 2 在模型中使用S-FUNCTION.................................................................................................................... 3 向S-Function 传递参数..................................................................................................................... 3 何时使用S-Function......................................................................................................................... 4 S-FUNCTION 的工作原理........................................................................................................................ 5 Simulink 块的数学关系...................................................................................................................... 5 仿真过程............................................................................................................................................. 5 S-Function 回调程序.......................................................................................................................... 6 S-FUNCTION 的实现................................................................................................................................ 8 M-文件的S-Function........................................................................................................................ 8 MEX 文件的S-function ..................................................................................................................... 8 MEX 文件与M-文件的S-function 比较........................................................................................... 9 S-FUNCTION 的概念.............................................................................................................................. 10 直接馈通........................................................................................................................................... 10 动态维矩阵....................................................................................................................................... 10 设置采样时间和偏移量.....................................................................................................................11 S-FUNCTION 范例................................................................................................................................. 14 M 文件S-function 范例.................................................................................................................... 15 C S-Function 范例............................................................................................................................ 16 Fortran S-Function 范例.................................................................................................................. 18 C++ S-Function 范例....................................................................................................................... 18 Ada S-Function 范例....................................................................................................................... 18 编写M S-FUNCTION............................................................................................................................. 19 概述....................................................................................................................................................... 20 S-Function 参数................................................................................................................................ 20 S-Function 的输出............................................................................................................................ 20 定义S-FUNCTION 块特性..................................................................................................................... 22 处理S-FUNCTION 参数......................................................................................................................... 22 M 文件的S-FUNCTION 范例................................................................................................................. 23 范例1——简单的M 文件S-Function ........................................................................................... 23 范例2——连续状态S-Function .................................................................................................... 25 范例3——离散状态S-Function .................................................................................................... 27 范例4——混合系统S-Function .................................................................................................... 28 范例5——变步长S-Function ........................................................................................................ 31 ii 使用C 语言编写S-FUNCTION ............................................................................................................. 33 概述....................................................................................................................................................... 34 创建C MEX S-Function.................................................................................................................. 35 自动生成S-FUNCTION......................................................................................................................... 36 配置生成的S-Function.................................................................................................................... 37 S-Function Builder 如何生成S-Function...................................................................................... 37 设置include 路径............................................................................................................................. 37 S-FUNCTION BUILDER 的对话窗........................................................................................................... 39 Initialization 选卡.............................................................................................................................. 39 Data Properties 选卡....................................................................................................................... 40 Libraries 选卡................................................................................................................................... 42 Outputs 选卡.................................................................................................................................... 43 Continuous Derivatives 选卡.......................................................................................................... 45 Discrete Update 选卡...................................................................................................................... 46 Build Info 选卡................................................................................................................................. 47 一个基本的C MEX S-FUNCTION 范例............................................................................................... 48 定义与包含....................................................................................................................................... 49 回调函数的实现................................................................................................................................ 50 Simulink/Real-Time Workshop 接口............................................................................................. 51 Building Timestwo 范例................................................................................................................... 51 C S-FUNCTION 模板.............................................................................................................................. 52 S-Function 源文件必需的内容........................................................................................................ 52 SimStruct.......................................................................................................................................... 53 编译C S-Function........................................................................................................................... 53 SIMULINK 如何与C S-FUNCTION 相互作用........................................................................................ 54 进程层面........................................................................................................................................... 54 数据层面........................................................................................................................................... 56 编写回调函数....................................................................................................................................... 59 将LEVEL 1 C MEX S-FUNCTION 转换到LEVEL 2 .............................................................................. 60 创建C++ S-FUNCTION......................................................................................................................... 63 创建ADA S-FUNCTION........................................................................................................................ 64 创建FORTRAN S-FUNCTION.............................................................................................................. 65 实现块特性............................................................................................................................................... 67 对话框参数........................................................................................................................................... 68 iii 可调参数........................................................................................................................................... 68 运行参数............................................................................................................................................... 70 创建运行参数................................................................................................................................... 70 更新运行参数................................................................................................................................... 71 创建输入和输出端口............................................................................................................................ 72 创建输入端口................................................................................................................................... 72 创建输出端口................................................................................................................................... 73 输入的标量扩展................................................................................................................................ 74 掩码多端口S-Function.................................................................................................................... 75 自定义数据类型................................................................................................................................... 76 采样时间............................................................................................................................................... 77 基于块的采样时间............................................................................................................................ 77 指定基于端口的采样时间................................................................................................................ 79 基于块与基于端口的混合采样时间................................................................................................ 81 多速率S-Function 块....................................................................................................................... 82 多速率S-Function 块的同步........................................................................................................... 83 工作向量............................................................................................................................................... 84 工作向量与过零检测........................................................................................................................ 85 包括指针工作向量的范例................................................................................................................ 85 内存分配........................................................................................................................................... 86 FUNCTION-CALL 子系统........................................................................................................................ 87 错误处理............................................................................................................................................... 89 防超程代码....................................................................................................................................... 89 SsSetErrorStatus 的终止条件........................................................................................................ 90 数组边界检查................................................................................................................................... 90 S-FUNCTION 范例................................................................................................................................. 91 连续状态的S-Function 范例........................................................................................................... 92 离散状态的S-Function 范例........................................................................................................... 93 混合系统的S-Function 范例........................................................................................................... 93 变步长的S-Function 范例............................................................................................................... 94 过零检测的S-Function 范例........................................................................................................... 94 时变连续传递函数的S-Function 范例........................................................................................... 94

声明:本文内容及配图由入驻作者撰写或者入驻合作网站授权转载。文章观点仅代表作者本人,不代表电子发烧友网立场。文章及其配图仅供工程师学习之用,如有内容侵权或者其他违规问题,请联系本站处理。 举报投诉

评论(1)
发评论
gibson 2012-09-07
0 回复 举报

!!!!
收起回复

下载排行榜

全部1条评论

快来发表一下你的评论吧 !