Simulink.Pdf
Total Page:16
File Type:pdf, Size:1020Kb
Simulink ® Simulation and Model-Based Design Using Simulink® Version 6 How to Contact The MathWorks: www.mathworks.com Web comp.soft-sys.matlab Newsgroup [email protected] Technical support [email protected] Product enhancement suggestions [email protected] Bug reports [email protected] Documentation error reports [email protected] Order status, license renewals, passcodes [email protected] Sales, pricing, and general information 508-647-7000 Phone 508-647-7001 Fax The MathWorks, Inc. Mail 3 Apple Hill Drive Natick, MA 01760-2098 For contact information about worldwide offices, see the MathWorks Web site. Using Simulink COPYRIGHT 1990 - 2004 by The MathWorks, Inc. The software described in this document is furnished under a license agreement. The software may be used or copied only under the terms of the license agreement. No part of this manual may be photocopied or repro- duced in any form without prior written consent from The MathWorks, Inc. FEDERAL ACQUISITION: This provision applies to all acquisitions of the Program and Documentation by, for, or through the federal government of the United States. By accepting delivery of the Program or Docu- mentation, the government hereby agrees that this software or documentation qualifies as commercial computer software or commercial computer software documentation as such terms are used or defined in FAR 12.212, DFARS Part 227.72, and DFARS 252.227-7014. Accordingly, the terms and conditions of this Agreement and only those rights specified in this Agreement, shall pertain to and govern the use, modifica- tion, reproduction, release, performance, display, and disclosure of the Program and Documentation by the federal government (or other entity acquiring for or through the federal government) and shall supersede any conflicting contractual terms or conditions. If this License fails to meet the government's needs or is incon- sistent in any respect with federal procurement law, the government agrees to return the Program and Docu- mentation, unused, to The MathWorks, Inc. MATLAB, Simulink, Stateflow, Handle Graphics, and Real-Time Workshop are registered trademarks, and TargetBox is a trademark of The MathWorks, Inc. Other product or brand names are trademarks or registered trademarks of their respective holders. Printing History: November 1990 First printing New for Simulink 1 December 1996 Second printing Revised for Simulink 2 January 1999 Third printing Revised for Simulink 3 (Release 11) November 2000 Fourth printing Revised for Simulink 4 (Release 12) July 2002 Fifth printing Revised for Simulink 5 (Release 13) April 2003 Online only Revised for Simulink 5.1 (Release 13SP1) April 2004 Online only Revised for Simulink 5.1.1 (Release 13SP1+) June 2004 Sixth printing Revised for Simulink 6.0 (Release 14) Contents Getting Started 1 What Is Simulink? . 1-2 Tool for Interactive Simulation . 1-2 Tool for Model-Based Design . 1-2 Related Products . 1-3 Running a Demo Model . 1-4 Description of the Demo . 1-5 Some Things to Try . 1-6 What This Demo Illustrates . 1-7 Other Useful Demos . 1-7 Building a Model . 1-9 Setting Simulink Preferences . 1-18 Miscellaneous Preferences . 1-19 Font Preferences . 1-20 Simulation Preferences . 1-21 How Simulink Works 2 Introduction . 2-2 Modeling Dynamic Systems . 2-3 Block Diagram Semantics . 2-3 Creating Models . 2-4 Time . 2-4 States . 2-4 Block Parameters . 2-7 Tunable Parameters . 2-8 Block Sample Times . 2-8 i Custom Blocks . 2-9 Systems and Subsystems . 2-9 Signals . 2-10 Block Methods . 2-11 Model Methods . 2-12 Simulating Dynamic Systems . 2-13 Model Compilation . 2-13 Link Phase . 2-15 Simulation Loop Phase . 2-15 Solvers . 2-17 Zero-Crossing Detection . 2-19 Algebraic Loops . 2-24 Modeling and Simulating Discrete Systems . 2-31 Specifying Sample Time . 2-31 Purely Discrete Systems . 2-35 Multirate Systems . 2-35 Determining Step Size for Discrete Systems . 2-36 Sample Time Propagation . 2-37 Mixed Continuous and Discrete Systems . 2-40 Simulink Basics 3 Starting Simulink . 3-2 Opening Models . 3-4 Avoiding Initial Model Open Delay . 3-4 Entering Simulink Commands . 3-5 Using the Simulink Menu Bar to Enter Commands . 3-5 Using Context-Sensitive Menus to Enter Commands . 3-5 Using the Simulink Toolbar to Enter Commands . 3-5 Using the MATLAB Window to Enter Commands . 3-6 Undoing a Command . 3-6 ii Contents Simulink Windows . 3-7 Status Bar . 3-7 Zooming Block Diagrams . 3-7 Panning Block Diagrams . 3-8 Saving a Model . 3-9 Saving a Model in Earlier Formats . 3-9 Printing a Block Diagram . 3-12 Print Dialog Box . 3-12 Print Command . 3-13 Specifying Paper Size and Orientation . 3-14 Positioning and Sizing a Diagram . 3-15 Generating a Model Report . 3-16 Model Report Options . 3-17 Summary of Mouse and Keyboard Actions . 3-19 Manipulating Blocks . 3-19 Manipulating Lines . 3-20 Manipulating Signal Labels . 3-20 Manipulating Annotations . 3-21 Ending a Simulink Session . 3-22 Creating a Model 4 Creating a New Model . 4-2 Selecting Objects . 4-3 Selecting One Object . 4-3 Selecting More Than One Object . 4-3 Specifying Block Diagram Colors . 4-5 Choosing a Custom Color . 4-5 Defining a Custom Color . 4-6 iii Specifying Colors Programmatically . 4-6 Displaying Sample Time Colors . 4-7 Connecting Blocks . 4-9 Automatically Connecting Blocks . 4-9 Manually Connecting Blocks . 4-11 Disconnecting Blocks . 4-15 Annotating Diagrams . 4-16 Using TeX Formatting Commands in Annotations . 4-17 Creating Annotations Programmatically . 4-18 Creating Subsystems . 4-20 Creating a Subsystem by Adding the Subsystem Block . 4-20 Creating a Subsystem by Grouping Existing Blocks . 4-21 Model Navigation Commands . 4-23 Window Reuse . 4-23 Labeling Subsystem Ports . 4-24 Controlling Access to Subsystems . 4-24 Creating Conditionally Executed Subsystems . 4-26 Enabled Subsystems . ..