ebook img

Simulink - User Guide PDF

4090 Pages·2017·38.87 MB·English
by  
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Simulink - User Guide

® Simulink User's Guide R2017b How to Contact MathWorks Latest news: www.mathworks.com Sales and services: www.mathworks.com/sales_and_services User community: www.mathworks.com/matlabcentral Technical support: www.mathworks.com/support/contact_us Phone: 508-647-7000 The MathWorks, Inc. 3 Apple Hill Drive Natick, MA 01760-2098 ® Simulink User's Guide © COPYRIGHT 1990–2017 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 reproduced 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 Documentation, 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, modification, 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 inconsistent in any respect with federal procurement law, the government agrees to return the Program and Documentation, unused, to The MathWorks, Inc. Trademarks MATLAB and Simulink are registered trademarks of The MathWorks, Inc. See www.mathworks.com/trademarks for a list of additional trademarks. Other product or brand names may be trademarks or registered trademarks of their respective holders. Patents MathWorks products are protected by one or more U.S. patents. Please see www.mathworks.com/patents for more information. Revision 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 5.0 (Release 14) October 2004 Seventh printing Revised for Simulink 6.1 (Release 14SP1) March 2005 Online only Revised for Simulink 6.2 (Release 14SP2) September 2005 Eighth printing Revised for Simulink 6.3 (Release 14SP3) March 2006 Online only Revised for Simulink 6.4 (Release 2006a) March 2006 Ninth printing Revised for Simulink 6.4 (Release 2006a) September 2006 Online only Revised for Simulink 6.5 (Release 2006b) March 2007 Online only Revised for Simulink 6.6 (Release 2007a) September 2007 Online only Revised for Simulink 7.0 (Release 2007b) March 2008 Online only Revised for Simulink 7.1 (Release 2008a) October 2008 Online only Revised for Simulink 7.2 (Release 2008b) March 2009 Online only Revised for Simulink 7.3 (Release 2009a) September 2009 Online only Revised for Simulink 7.4 (Release 2009b) March 2010 Online only Revised for Simulink 7.5 (Release 2010a) September 2010 Online only Revised for Simulink 7.6 (Release 2010b) April 2011 Online only Revised for Simulink 7.7 (Release 2011a) September 2011 Online only Revised for Simulink 7.8 (Release 2011b) March 2012 Online only Revised for Simulink 7.9 (Release 2012a) September 2012 Online only Revised for Simulink 8.0 (Release 2012b) March 2013 Online only Revised for Simulink 8.1 (Release 2013a) September 2013 Online only Revised for Simulink 8.2 (Release 2013b) March 2014 Online only Revised for Simulink 8.3 (Release 2014a) October 2014 Online only Revised for Simulink 8.4 (Release 2014b) March 2015 Online only Revised for Simulink 8.5 (Release 2015a) September 2015 Online only Revised for Simulink 8.6 (Release 2015b) October 2015 Online only Rereleased for Simulink 8.5.1 (Release 2015aSP1) March 2016 Online only Revised for Simulink 8.7 (Release 2016a) September 2016 Online only Revised for Simulink 8.8 (Release 2016b) March 2017 Online only Revised for Simulink 8.9 (Release 2017a) September 2017 Online only Revised for Simulink 9.0 (Release 2017b) Contents Introduction to Simulink Simulink Basics 1 Start the Simulink Software . . . . . . . . . . . . . . . . . . . . . . . 1-2 Start the MATLAB Software . . . . . . . . . . . . . . . . . . . . . 1-2 Open the Simulink Editor . . . . . . . . . . . . . . . . . . . . . . . . 1-2 Open the Library Browser . . . . . . . . . . . . . . . . . . . . . . . 1-3 Create and Open Models . . . . . . . . . . . . . . . . . . . . . . . . . . 1-5 Create a Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-5 Use Customized Settings When Creating New Models . . 1-8 Open a Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-9 Load Variables When Opening a Model . . . . . . . . . . . . 1-10 Open a Model with Different Character Encoding . . . . . 1-11 Simulink Model File Types . . . . . . . . . . . . . . . . . . . . . . 1-11 Programmatic Modeling Basics . . . . . . . . . . . . . . . . . . . . 1-13 Load a Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-13 Create a Model and Specify Parameter Settings . . . . . . 1-13 Programmatically Load Variables When Opening a Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-14 Programmatically Add and Connect Blocks . . . . . . . . . . 1-15 Name a Signal Programmatically . . . . . . . . . . . . . . . . . 1-17 Open the Same Model in Multiple Windows . . . . . . . . . 1-17 Get a Simulink Identifier . . . . . . . . . . . . . . . . . . . . . . . 1-18 Specify Colors Programmatically . . . . . . . . . . . . . . . . . 1-21 Build and Edit a Model in the Simulink Editor . . . . . . . 1-23 Start Simulink and Create a Model . . . . . . . . . . . . . . . . 1-23 Add Blocks to the Model . . . . . . . . . . . . . . . . . . . . . . . . 1-23 Align and Connect Blocks . . . . . . . . . . . . . . . . . . . . . . . 1-24 v Set Block Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . 1-25 Add More Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-26 Branch a Connection . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-27 Organize Your Model . . . . . . . . . . . . . . . . . . . . . . . . . . 1-29 Simulate Model and View Results . . . . . . . . . . . . . . . . . 1-31 Modify the Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-33 Save a Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-37 How to Tell If a Model Needs Saving . . . . . . . . . . . . . . . 1-37 Save a Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-37 What Happens When You Save a Model? . . . . . . . . . . . 1-38 Save Models in the SLX File Format . . . . . . . . . . . . . . . 1-39 Save Models with Different Character Encodings . . . . . 1-41 Export a Model to a Previous Simulink Version . . . . . . 1-43 Save from One Earlier Simulink Version to Another . . . 1-44 Model Editing Environment . . . . . . . . . . . . . . . . . . . . . . 1-45 Simulink Editor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-45 Interactive Model Building . . . . . . . . . . . . . . . . . . . . . . 1-47 Model Design Error Detection . . . . . . . . . . . . . . . . . . . . 1-48 Library Browser . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-48 Setting Properties and Parameters . . . . . . . . . . . . . . . . 1-50 Parts of a Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-53 About Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-53 Block Parameters and Properties in Simulink . . . . . . . . 1-54 Signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-56 Preview Content of Hierarchical Items . . . . . . . . . . . . . 1-58 What Is Content Preview? . . . . . . . . . . . . . . . . . . . . . . 1-58 Enable Content Preview . . . . . . . . . . . . . . . . . . . . . . . . 1-59 What Content Preview Displays . . . . . . . . . . . . . . . . . . 1-59 Use Viewmarks to Save Views of Models . . . . . . . . . . . . 1-61 What Are Viewmarks? . . . . . . . . . . . . . . . . . . . . . . . . . 1-61 Create a Viewmark . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-62 Open and Navigate Viewmarks . . . . . . . . . . . . . . . . . . . 1-63 Manage Viewmarks . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-63 Refresh a Viewmark . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-64 Update Diagram and Run Simulation . . . . . . . . . . . . . . 1-65 Updating the Diagram . . . . . . . . . . . . . . . . . . . . . . . . . 1-65 Simulation Updates the Diagram . . . . . . . . . . . . . . . . . 1-65 vi Contents Update Diagram While Editing . . . . . . . . . . . . . . . . . . . 1-65 Simulate a Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-66 Print Model Diagrams . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-68 Print Interactively or Programmatically . . . . . . . . . . . . 1-68 Printing Options . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-68 Canvas Color . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-68 Basic Printing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-70 Print the vdp Model Using Default Settings . . . . . . . . . 1-70 Print a Subsystem Hierarchy . . . . . . . . . . . . . . . . . . . . 1-72 Select the Systems to Print . . . . . . . . . . . . . . . . . . . . . . . 1-74 Print Current System . . . . . . . . . . . . . . . . . . . . . . . . . . 1-74 Print Subsystems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-74 Print a Model Referencing Hierarchy . . . . . . . . . . . . . . 1-75 Specify the Page Layout and Print Job . . . . . . . . . . . . . 1-77 Page and Print Job Setup . . . . . . . . . . . . . . . . . . . . . . . 1-77 Set Paper Size and Orientation Without Printing . . . . . 1-77 Tiled Printing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-78 Print Multiple Pages for Large Models . . . . . . . . . . . . . . 1-79 Add a Log of Printed Models . . . . . . . . . . . . . . . . . . . . . . 1-80 Add a Sample Time Legend . . . . . . . . . . . . . . . . . . . . . . . 1-81 Print from the MATLAB Command Line . . . . . . . . . . . . 1-82 Printing Commands . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-82 Print Systems with Multiline Names or Names with Spaces . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-82 Set Paper Orientation and Type . . . . . . . . . . . . . . . . . . 1-83 Position and Size a System . . . . . . . . . . . . . . . . . . . . . . 1-83 Use Tiled Printing . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-84 Print to a PDF . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-86 Print Model Reports . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-87 Model Report Options . . . . . . . . . . . . . . . . . . . . . . . . . . 1-88 vii Print Models to Image File Formats . . . . . . . . . . . . . . . . 1-90 Copy Model Views to Third-Party Applications . . . . . . . 1-90 Keyboard and Mouse Actions for Simulink Modeling . . 1-91 Object Selection and Clipboard Operations . . . . . . . . . . 1-91 Block and Signal Line Shortcuts and Actions . . . . . . . . 1-92 Signal Name and Label Actions . . . . . . . . . . . . . . . . . . 1-93 Simulation Keyboard Shortcuts . . . . . . . . . . . . . . . . . . 1-94 Debugging and Breakpoints Keyboard Shortcuts . . . . . 1-94 Zooming and Scrolling Shortcuts . . . . . . . . . . . . . . . . . . 1-94 Library Browser Shortcuts . . . . . . . . . . . . . . . . . . . . . . 1-95 File Operations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1-96 Simulation Stepping 2 How Simulation Stepper Helps With Model Analysis . . . 2-2 How Stepping Through a Simulation Works . . . . . . . . . . 2-3 Simulation Snapshots . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-3 How Simulation Stepper Uses Snapshots . . . . . . . . . . . . 2-4 How Simulation Stepper Differs from Simulink Debugger . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-5 Use Simulation Stepper . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-8 Simulation Stepper Access . . . . . . . . . . . . . . . . . . . . . . . 2-8 Simulation Stepper Pause Status . . . . . . . . . . . . . . . . . . 2-8 Tune Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-9 Referenced Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-10 Simulation Stepper and Interval Logging . . . . . . . . . . . 2-10 Simulation Stepper and Stateflow Debugger . . . . . . . . . 2-10 Simulation Stepper Limitations . . . . . . . . . . . . . . . . . . . 2-12 Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-12 Model Configuration . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-12 Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-12 Step Through a Simulation . . . . . . . . . . . . . . . . . . . . . . . 2-15 Step Forward and Back . . . . . . . . . . . . . . . . . . . . . . . . 2-15 viii Contents Set Conditional Breakpoints for Stepping a Simulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 2-18 Add and Edit Conditional Breakpoints . . . . . . . . . . . . . 2-18 Observe Conditional Breakpoint Values . . . . . . . . . . . . 2-19 How Simulink Works 3 How Simulink Works . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-2 Modeling Dynamic Systems . . . . . . . . . . . . . . . . . . . . . . . . 3-3 Block Diagram Semantics . . . . . . . . . . . . . . . . . . . . . . . . 3-3 Creating Models . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4 Time . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-4 States . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-5 Block Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-8 Tunable Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-8 Block Sample Times . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-9 Custom Blocks . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-9 Systems and Subsystems . . . . . . . . . . . . . . . . . . . . . . . 3-10 Signals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-14 Block Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-15 Model Methods . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-16 Simulation Phases in Dynamic Systems . . . . . . . . . . . . . 3-17 Model Compilation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-17 Link Phase . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-18 Simulation Loop Phase . . . . . . . . . . . . . . . . . . . . . . . . . 3-18 Solvers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-21 Fixed-Step Solvers Versus Variable-Step Solvers . . . . . 3-21 Continuous Versus Discrete Solvers . . . . . . . . . . . . . . . 3-21 Minor Time Steps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-22 Shape Preservation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-22 Zero-Crossing Detection . . . . . . . . . . . . . . . . . . . . . . . . . . 3-24 Demonstrating Effects of Excessive Zero-Crossing Detection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-24 How the Simulator Can Miss Zero-Crossing Events . . . 3-29 Preventing Excessive Zero Crossings . . . . . . . . . . . . . . 3-29 ix Zero-Crossing Algorithms . . . . . . . . . . . . . . . . . . . . . . . 3-31 Understanding Signal Threshold . . . . . . . . . . . . . . . . . 3-32 How Blocks Work with Zero-Crossing Detection . . . . . . 3-33 Algebraic Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-37 What Is an Algebraic Loop? . . . . . . . . . . . . . . . . . . . . . 3-37 Interpretations of Algebraic Loops . . . . . . . . . . . . . . . . 3-38 What is an Artificial Algebraic Loop? . . . . . . . . . . . . . . 3-41 Why Algebraic Loops Are Undesirable . . . . . . . . . . . . . 3-42 Identify Algebraic Loops in Your Model . . . . . . . . . . . . 3-43 How to Handle Algebraic Loops in a Model . . . . . . . . . . 3-46 How the Algebraic Loop Solver Works . . . . . . . . . . . . . 3-48 Remove Algebraic Loops . . . . . . . . . . . . . . . . . . . . . . . . 3-50 Remove Artificial Algebraic Loops . . . . . . . . . . . . . . . . . 3-53 How Simulink Eliminates Artificial Algebraic Loops . . . 3-64 When Simulink Cannot Eliminate Artificial Algebraic Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-70 Managing Large Models with Artificial Algebraic Loops . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-72 Model Blocks and Direct Feedthrough . . . . . . . . . . . . . 3-73 Changing Block Priorities When Using Algebraic Loop Solver . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 3-74 Modeling Dynamic Systems Creating a Model 4 Create a Template from a Model . . . . . . . . . . . . . . . . . . . . 4-2 Describe Models Using Annotations . . . . . . . . . . . . . . . . . 4-3 Add a Text Annotation . . . . . . . . . . . . . . . . . . . . . . . . . . 4-3 Resize an Annotation . . . . . . . . . . . . . . . . . . . . . . . . . . . 4-4 Make an Annotation Interactive . . . . . . . . . . . . . . . . . . . 4-4 Add an Image Annotation . . . . . . . . . . . . . . . . . . . . . . . . 4-5 Use TeX Commands in an Annotation . . . . . . . . . . . . . . 4-5 Add Lines to Connect Annotations to Blocks . . . . . . . . . . 4-6 x Contents

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.