第六章Simulink基础 Chapter 6:Introduction to Simulink 一.Simulink初步(Primer of Simulink) MATLAB Simulink是一个动态仿真系统,用于对动态系统进行仿真和 分析,预先模拟实际系统的特性和响应,根据设计和使用要求,对系统进行 修改和优化。 Simulink提供了图形化用户界面,只须点击鼠标就可以轻易的完成模型 的创建、调试和仿真工作,用户不须专门掌握一种程序设计语言。 Simulink可将系统分为从高级到低级的几个层次,每层又可以细分为几 个部分,每层系统构建完成后,将各层连接起来构成一个完整系统。 模型创建完成后,可以启动系统的仿真功能分析系统的动态特性,其内 置的分析工具包括各种仿真算法、系统线性化、寻求平衡点等。仿真结果可 以以图形方式在示波器窗口显示,也可将输出结果以变量形式保存起来,并 输入到MATLAB中以完成进一步的分析。 Simulink可以仿真线性和非线性系统,并能创建连续时间、离散时间或 二者混合的系统。支持多采样频率系统。 Simulink Version 6.0(R14)05-May-2004 Model analysis and construction functions. Simulation sim Simulate a Simulink model sldebug -Debug a Simulink model. simset Define options to SIM Options structure. simget Get SIM Options structure Linearization and trimming. linmod Extract linear model from continuous-time system. linmod2 -Extractlinear model,advanced method. dlinmod -Extract linear model from discrete-time system
第六章 Simulink 基础 Chapter 6: Introduction to Simulink 一.Simulink 初步(Primer of Simulink) MATLAB Simulink 是一个动态仿真系统,用于对动态系统进行仿真和 分析,预先模拟实际系统的特性和响应,根据设计和使用要求,对系统进行 修改和优化。 Simulink 提供了图形化用户界面,只须点击鼠标就可以轻易的完成模型 的创建、调试和仿真工作,用户不须专门掌握一种程序设计语言。 Simulink 可将系统分为从高级到低级的几个层次,每层又可以细分为几 个部分,每层系统构建完成后,将各层连接起来构成一个完整系统。 模型创建完成后,可以启动系统的仿真功能分析系统的动态特性,其内 置的分析工具包括各种仿真算法、系统线性化、寻求平衡点等。仿真结果可 以以图形方式在示波器窗口显示,也可将输出结果以变量形式保存起来,并 输入到 MATLAB 中以完成进一步的分析。 Simulink 可以仿真线性和非线性系统,并能创建连续时间、离散时间或 二者混合的系统。支持多采样频率系统。 Simulink Version 6.0 (R14) 05-May-2004 Model analysis and construction functions. Simulation sim - Simulate a Simulink model. sldebug - Debug a Simulink model. simset - Define options to SIM Options structure. simget - Get SIM Options structure Linearization and trimming. linmod - Extract linear model from continuous-time system. linmod2 - Extract linear model, advanced method. dlinmod - Extract linear model from discrete-time system
trim Find steady-state operating point. Model Construction. close system -Close open model or block. new_system -Create new empty model window. open_system -Open existing model or block. load_system Load existing model without making model visible. save_system -Save an open model add_block -Add new block. add line -Add new line. delete_block -Remove block. delete line Remove line. find_system -Search a model. hilite system -Hilite objects within a model. replace block -Replace existing blocks with a new block. set_param -Set parameter values for model or block. get_param -Get simulation parameter values from model. add param Add a user-defined string parameter to a model delete_param Delete a user-defined parameter from a model bdclose Close a Simulink window. bdroot -Rootlevel model name. gcb Get the name of the current block. gcbh Get the handle of the current block. ges Get the name of the current system. getfullname get the full path name of a block slupdate Update older 1.x models to 3.x. addterms -Add terminators to unconnected ports. boolean -Convert numeric array to boolean slhelp Simulink user's guide or block help
trim - Find steady-state operating point. Model Construction. close_system - Close open model or block. new_system - Create new empty model window. open_system - Open existing model or block. load_system - Load existing model without making model visible. save_system - Save an open model. add_block -Add new block. add_line - Add new line. delete_block - Remove block. delete_line - Remove line. find_system - Search a model. hilite_system - Hilite objects within a model. replace_block - Replace existing blocks with a new block. set_param - Set parameter values for model or block. get_param - Get simulation parameter values from model. add_param - Add a user-defined string parameter to a model. delete_param - Delete a user-defined parameter from a model. bdclose - Close a Simulink window. bdroot - Root level model name. gcb - Get the name of the current block. gcbh - Get the handle of the current block. gcs - Get the name of the current system. getfullname - get the full path name of a block slupdate - Update older 1.x models to 3.x. addterms -Add terminators to unconnected ports. boolean - Convert numeric array to boolean. slhelp - Simulink user's guide or block help
Masking. hasmask -Check for mask. hasmaskdlg Check for mask dialog hasmaskicon -Check for mask icon. iconedit -Design block icons using ginput function. maskpopups -Return and change masked block's popup menu items. movemask Restructure masked built-in blocks as masked subsystems. Library. libinfo Get library information for a system. Diagnostics. sllastdiagnostic-Last diagnostic array. sllasterror Last error array. sllastwarning Last warning array. sldiagnostics Get block count and compile stats for a model. Hardcopy and printing frameedit Edit print frames for annotated model printouts. print Print graph or Simulink system;or save graph to M-file. printopt -Printer defaults. orient -Set paper orientation. simulink is both a directory and a function. Copyright 1990-2004 The Math Works,Inc. Simulink的三大步骤(procedure of Simulink):
Masking. hasmask - Check for mask. hasmaskdlg - Check for mask dialog. hasmaskicon - Check for mask icon. iconedit - Design block icons using ginput function. maskpopups - Return and change masked block's popup menu items. movemask - Restructure masked built-in blocks as masked subsystems. Library. libinfo - Get library information for a system. Diagnostics. sllastdiagnostic - Last diagnostic array. sllasterror - Last error array. sllastwarning - Last warning array. sldiagnostics - Get block count and compile stats for a model. Hardcopy and printing. frameedit - Edit print frames for annotated model printouts. print - Print graph or Simulink system; or save graph to M-file. printopt - Printer defaults. orient - Set paper orientation. simulink is both a directory and a function. Copyright 1990-2004 The MathWorks, Inc. Simulink 的三大步骤(procedure of Simulink):
模型创建与定义、(Model creating and definition) 模型的分析、(Model analyzing 模型的修正。(Model modifying) 模型构建 和定义 模型的分析 Simulink的运行:(Running of Simulink) l、运行Simulink:命令窗口下点击Simulink图标(或键入Simulink命 令)→Simulink Library Browser(浏览器)→simulink树状列表形 式的模块库(包含simulink模块库中的各种模块及其它Toolbox和 Blockset中的模块) 2、选择建模模块:展开树状列表,用鼠标点击所需类别的模块项,所 选模块类的具体模块库就在右侧的列表框中显示出来,提供建模使用。 也可以在在输入栏中键入模块名并点击ind按钮进行查询。 3、打开模型创建窗口:(open the window of mode creating)。 在工具栏中选择“建立新模型”的图标,弹出名为Untitled的空白窗口, 选择Ope窗口可以打开存于硬盘中已建的模型,完成模型的运行或修 改。 二.Simulink的基本模块(basic module) simulink浏览器窗口左侧的simulink项上单击鼠标右键,弹出菜单 “Open the Simulink'Labrary'”选项,将打开simulink模块库窗口。 1.信号源模块:source,棋块及功能见(表8-1) 2.输出模块:Sinks,模块及功能见(表8-2)
模型创建与定义、( Model creating and definition) 模型的分析、(Model analyzing) 模型的修正。(Model modifying) Simulink 的运行:(Running of Simulink) 1、运行 Simulink:命令窗口下点击 Simulink 图标(或键入 Simulink 命 令)→ Simulink Library Browser(浏览器)→ simulink 树状列表形 式的模块库(包含 simulink 模块库中的各种模块及其它 Toolbox 和 Blockset 中的模块) 2、选择建模模块:展开树状列表,用鼠标点击所需类别的模块项, 所 选模块类的具体模块库就在右侧的列表框中显示出来,提供建模使用。 也可以在在输入栏中键入模块名并点击 Find 按钮进行查询。 3、打开模型创建窗口:(open the window of mode creating)。 在工具栏中选择“建立新模型”的图标,弹出名为 Untitled 的空白窗口, 选择 Open 窗口可以打开存于硬盘中已建的模型,完成模型的运行或修 改。 二.Simulink 的基本模块(basic module) simulink 浏览器窗口左侧的 simulink 项上单击鼠标右键,弹出菜单 “Open the ‘Simulink’Labrary’”选项,将打开 simulink 模块库窗口。 1.信号源模块:source,模块及功能见(表 8—1) 2.输出模块:Sinks, 模块及功能见(表 8—2) 模型构建 和定义 模型的分析 显 示 修 正
3.连续系统模块:Continuous,模块及功能见(表8一3) 4.离散系统模块:Discrete,模块及功能见(表8一4) 5.数学运算模块:Math,模块及功能见(表8一5) 6.函数和表模块:Function&Tables,模块及功能见(表86) 7.非线性系统模块:Nonlinear,模块及功能见(表87) 8.信号与系统模块:Signal&Systems,模块及功能见(表88) 三.Simulink建模(Simulinc module creating) L.模块的创建与操作(Creatingand operation of Simulink) (I)创建模块:(module creating) (1)在浏览器列表中点击需要的模块,按住鼠标左键并拖曳至模型窗口 即可。 (2)双击模块可在弹出的对话框中修改相应的模块参数 (3)在模块下方名称处双击可改变模块名称。 (2)模块操作(module operation) (a)模块的选择(module selection) (b)移动模块(module moving) (c)模块的缩放(modulee sealing) (d)复制模块:(module copy) 四种方法: 大在选定模块处,按下鼠标右键并拖动至适当位置: *选定模块,在工具栏中(或Edit菜单中)选中Copy与Paste按 钮; *在选定的模块处点击鼠标右键,在弹出的菜单中选择C0py与 Paste选项; +按住”Ct”键,按下鼠标左键,将选定的模块拖至适当的位置。 (e)模块的旋转与翻转:(Rotating and turnover of module) 旋转:(rotate)将鼠标指向要翻转的模块并按下鼠标右键,选择弹出菜单 中的Format栏中的Rotate项,模块顺时针旋转90°。 翻转:将鼠标指向要翻转的模块并按下鼠标右键,选择弹出菜单中的 Format栏中的Flip Block项,模块顺时针旋转180
3. 连续系统模块: Continuous, 模块及功能见(表 8—3) 4. 离散系统模块:Discrete, 模块及功能见(表 8—4) 5. 数学运算模块:Math, 模块及功能见(表 8—5) 6.函数和表模块: Function & Tables, 模块及功能见(表 8—6) 7. 非线性系统模块:Nonlinear, 模块及功能见(表 8—7) 8. 信号与系统模块:Signal & Systems, 模块及功能见(表 8—8) 三. Simulink 建模(Simulinc module creating) 1. 模块的创建与操作(Creating and operation of Simulink) (1) 创建模块:(module creating) (1)在浏览器列表中点击需要的模块,按住鼠标左键并拖曳至模型窗口 即可。 (2)双击模块可在弹出的对话框中修改相应的模块参数 (3)在模块下方名称处双击可改变模块名称。 (2)模块操作(module operation) (a)模块的选择(module selection) (b)移动模块 (module moving) (c)模块的缩放(modulee scaling) (d) 复制模块:(module copy) 四种方法: * 在选定模块处,按下鼠标右键并拖动至适当位置; * 选定模块,在工具栏中(或 Edit 菜单中)选中 Copy 与 Paste 按 钮; * 在选定的模块处点击鼠标右键,在弹出的菜单中选择 Copy 与 Paste 选项; * 按住”Ctrl”键,按下鼠标左键,将选定的模块拖至适当的位置。 (e)模块的旋转与翻转:(Rotating and turnover of module) 旋转:(rotate)将鼠标指向要翻转的模块并按下鼠标右键,选择弹出菜单 中的 Format 栏中的 Rotate 项,模块顺时针旋转90o。 翻转:将鼠标指向要翻转的模块并按下鼠标右键,选择弹出菜单中的 Format 栏中的 Flip Block 项,模块顺时针旋转 180o