科学计算科学计算 (51).pdf
9.1 Basic Operations of Simulink Simulation9.2 Creation and Mask of Subsystem9.3 Design and Application of the S-Function9.4 Example of Simulink Simulation ApplicationChapterChapter 9 9 SimulinkSimulink SystemSystem SimulationSimulation9.19.1 Basic Operations of Simulink Basic Operations of Simulink SimulationSimulationSimulinks startThe creation of system simulation modelSimulation parameter settings1 1SimulinkSimulink s s S Startart tSelect the Home tab in the MATLAB desktop,then click the new icon of the filecommand group,and then select the Simulink Model icon from the drop-down menu.Select the Home tab in the MATLAB desktop,and then click the Simulink icon inthe SIMULINK command group.Type simulink in the Command Window.A new simulation model can be created with the New icon of the File menu item.You canopen an established model file with the Open icon of the File menu item.Click the Library Browser icon in the model editing window to open the Simulink LibraryBrowser window.At this time,you can drag the blocks in the library of blocks to the modelediting window with the mouse,and then connect the blocks to form a simulation model.(1)Simulink Library Browser windowThe Simulink Library Browser window contains two panes.The left-hand pane lists all libraries of blocks in a tree list.Click a library of blocks to list its libraries of sub-blocks in the right-hand pane;Double-click the sub-blocks library icon to list all blocks of this library.2 2The The Creation Creation of of System Simulation ModelSystem Simulation ModelThe blocks library of Simulink is generally divided into two categories,one is the basic blocks library,namely,the Simulink blocks library.The other is professional blocks libraries with various types.If you double-click the icon of the continuous system sub-block library,the left-hand of the library browser window will expand all sub-blocks libraries of the Simulink basic blocks library meanwhile the continuous system sub-block library is selected.The right-hand displays each block of the continuous system sub-block library,which can be used for continuous system modeling.(2)Operation of Simulink blocksAdd blocks:First find the block in the Simulink library browser window,and then drag theblock to the model editing window with the mouse.Delete and copy blocks:First select the block,and then press the delete key;Or selectclipboard commands such as Cut,Copy,and Paste of the Edit menu item in the model editingwindow.Connection of the two blocks:First move the mouse pointer to the output port of one block.When the mouse pointer changes into a cross cursor,hold down the left mouse button andmove the mouse pointer to the input port of the other block.When the connecting line changesfrom a dotted line to a solid line,release the left mouse button to complete the connection ofthe two blocks.A branch of a connection line:Connect a line first,then move the mouse pointer to the branchpoint,press Ctrl key,and drag the mouse pointer to the input port of the target block,and thenrelease the mouse and Ctrl key.(3)Save model to diskSelect the Save icon or the Save as icon of the File menu item in the Simulink model editingwindow.Click the Save button in the toolbar of the model editing window.(4)Setting of block parametersDouble-click the block to be set.Select the block to be set,and select the block parameters command of Diagram menu.Right-click the block to be set and select the block parameters command from the shortcutmenu.The block parameters setting dialog box contains two parts,the upper part is the block function description,and the lower part is used for setting block parameters.Take the block parameters sine wave dialog box as an example,users can set its amplitude,bias,frequency,phase,sample time and other parameters.3 3Simulation Parameter SettingsSimulation Parameter SettingsSelect the model configuration parameters command in the Simulation menu item.The other is to click the model configuration parameters command in the toolbar.In the simulation parameters setting dialog box,simulation parameters are divided into 7 categories.The Solver parameter,which is used to set the starting and ending time of simulation.Select algorithms for solving differential equations and specify parameters for it,and select certain output options.To select a simulation algorithm,first set the algorithm category,whether being fixed step size or variable step size algorithm and then select a specific algorithm.(a)fixed step(b)variable stepAfter setting the simulation parameters,click the Run icon in the toolbar of the model editing window or select the Run command in the simulation menu item to start the simulation of the current model.Use Simulink simulation to display sine curve and cosine curve,meanwhile,display the variation curve of sint to cost.Steps in Simulink system simulationCreate the simulation model of the systemSet simulation parametersStart the simulation and analyze the simulation results