• Sonuç bulunamadı

User's Guide

N/A
N/A
Protected

Academic year: 2021

Share "User's Guide"

Copied!
3290
0
0

Yükleniyor.... (view fulltext now)

Tam metin

(1)

Simulink ®

User's Guide

(2)

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–2015 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.

(3)

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)

(4)
(5)

Contents

Introduction to Simulink

Simulink Basics

1

Start the Simulink Software . . . . 1-3 Open the MATLAB Software . . . 1-3 Open the Library Browser . . . 1-3 Open the Simulink Editor . . . 1-4 Open a Model . . . . 1-5 What Happens When You Open a Model . . . 1-5 Open an Existing Model . . . 1-5 Search for a Model in a File Browser . . . 1-6 Models with Different Character Encodings . . . 1-6 Avoid Initial Model Open Delay . . . 1-6 Load a Model . . . . 1-8 Load Variables When Loading a Model . . . 1-8 Save a Model . . . . 1-10 How to Tell If a Model Needs Saving . . . 1-10 Save a Model . . . 1-10 What Happens When You Save a Model? . . . 1-11 Saving Models in the SLX File Format . . . 1-12 Saving Models with Different Character Encodings . . . 1-14 Export a Model to a Previous Simulink Version . . . 1-16 Save from One Earlier Simulink Version to Another . . 1-16 Simulink Editor . . . . 1-18 Editor Layout . . . 1-18 Undoing Commands . . . 1-22

(6)

Window Management . . . 1-22 Zoom and Pan Models . . . . 1-24 Zoom the Displayed Size of a Model . . . 1-24 Pan to Areas in a Model . . . 1-24 Disable Mouse Scroll Wheel Zoom Behavior . . . 1-25 Preview Content of Hierarchical Items . . . . 1-26 What Is Content Preview? . . . 1-26 Enable Content Preview . . . 1-27 What Content Preview Displays . . . 1-27 Use Viewmarks to Save Views of Models . . . . 1-29 What Are Viewmarks? . . . 1-29 Create a Viewmark . . . 1-30 Open and Navigate Viewmarks . . . 1-31 Save a Viewmark with the Model . . . 1-31 Manage Viewmarks . . . 1-31 Refresh a Viewmark . . . 1-32 Update a Block Diagram . . . . 1-33 Updating the Diagram . . . 1-33 Simulation Updates the Diagram . . . 1-33 Update Diagram at Edit Time . . . 1-33 Printing Capabilities . . . . 1-35 Print Interactively or Programmatically . . . 1-35 Printing Options . . . 1-35 Canvas Color . . . 1-35 Print Model Reports . . . 1-36 Basic Printing . . . . 1-37 Print the vdp Model Using Default Settings . . . 1-37 Print a Subsystem Hierarchy . . . 1-39 Select the Systems to Print . . . . 1-42 Print Current System . . . 1-42 Print Subsystems . . . 1-42 Print a Model Referencing Hierarchy . . . 1-43 Specify the Page Layout and Print Job . . . . 1-44 Page and Print Job Setup . . . 1-44 Two Interfaces for Page and Print Job Setup . . . 1-44

(7)

Tiled Printing . . . . 1-45 Print Multiple Pages for Large Models . . . . 1-46 Add a Log of Printed Models . . . . 1-47 Add a Sample Time Legend . . . . 1-48 Print from the MATLAB Command Line . . . . 1-49 Printing Commands . . . 1-49 Print Systems with Multiline Names or Names with

Spaces . . . 1-49 Set Paper Orientation and Type . . . 1-50 Position and Size a System . . . 1-50 Use Tiled Printing . . . 1-51 Export Models to Third-Party Applications . . . . 1-53 Print to a PDF or Postscript File . . . . 1-54 Export Models to Image File Formats . . . . 1-55 Generate a Model Report . . . . 1-56 Model Report Options . . . 1-57 End a Simulink Session . . . . 1-59 Keyboard and Mouse Shortcuts for Simulink . . . . 1-60 Model Viewing Shortcuts . . . 1-60 Model Editing Shortcuts . . . 1-61 Library Browser Shortcuts . . . 1-61 Block Editing Shortcuts . . . 1-62 Masking Shortcuts . . . 1-63 Line Editing Shortcuts . . . 1-64 Signal Label Editing Shortcuts . . . 1-64 Annotation Editing Shortcuts . . . 1-64 Simulation and Code Generation Shortcuts . . . 1-65 Debugging and Breakpoints Shortcuts . . . 1-65

(8)

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 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 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

(9)

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-23

Demonstrating Effects of Excessive Zero-Crossing

Detection . . . 3-23 How the Simulator Can Miss Zero-Crossing Events . . . 3-28 Preventing Excessive Zero Crossings . . . 3-29 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

(10)

Managing Large Models with Artificial Algebraic Loops 3-72 Changing Block Priorities When Using Algebraic Loop

Solver . . . 3-73

Modeling Dynamic Systems

Creating a Model

4

Create a New Model . . . . 4-3 What Are Model Templates? . . . 4-3 Create a Model Using a Template . . . 4-3 Create an Empty Model . . . 4-3 Create a Template from a Model . . . . 4-5 Add Blocks To Models Using the Library Browser . . . . 4-7 Open the Library Browser . . . 4-7 Copy Blocks to Your Model . . . 4-7 Browse Block Libraries . . . 4-8 Search Block Libraries . . . 4-8 Copy Blocks to Models . . . 4-9 Select Modeling Objects . . . . 4-10 Select an Object . . . 4-10 Select Multiple Objects . . . 4-10 Specify Block Diagram Colors . . . . 4-12 Set Block Diagram Colors Interactively . . . 4-12 Platform Differences for Custom Colors . . . 4-12 Choose a Custom Color . . . 4-13 Define a Custom Color . . . 4-14 Specify Colors Programmatically . . . 4-15 Connect Blocks . . . . 4-16 Automatically Connect Blocks . . . 4-16 Manually Connect Blocks . . . 4-19 Disconnect Blocks . . . 4-25

(11)

Align, Distribute, and Resize Groups of Blocks . . . . 4-26 Box and Label Areas of a Model . . . . 4-27 Create an Area . . . 4-27 Move an Area . . . 4-28 Convert Area to a Subsystem . . . 4-28 Annotations . . . . 4-29 Possible Uses for Annotations . . . 4-29 What Are Annotations? . . . 4-29 Three Types of Annotations . . . 4-30 Annotation Layout and Contents . . . 4-31 Interactive Annotations . . . 4-32 Create an Annotation . . . . 4-33 Add and Lay Out an Annotation . . . 4-34 Add a Hyperlink and Format Text . . . 4-35 Add a Bulleted List . . . 4-35 Copy and Paste an Image from a Web Page . . . 4-36 Add a Numbered List . . . 4-36 Use TeX Commands in an Annotation . . . . 4-38 Add a TeX Annotation . . . 4-38 Add an Image-Only Annotation . . . . 4-40 Add an Image . . . 4-40 Change the Appearance of an Image . . . 4-40 Add Lines to Connect Annotations to Blocks . . . . 4-42 Show or Hide Annotations . . . . 4-43 Configure an Annotation for Hiding . . . 4-43 Hide Markup Annotations . . . 4-43 Make an Annotation Interactive . . . . 4-44 Annotation Callback Functions . . . 4-44 Associate Click Functions with Annotations . . . 4-44 Select and Edit Click-Function Annotations . . . 4-45 Create an Annotation Programmatically . . . . 4-46 Annotations API . . . 4-46 Create Annotations Programmatically . . . 4-46 Delete an Annotation Programmatically . . . 4-47

(12)

Find Annotations in a Model . . . 4-47 Show or Hide Annotations Programmatically . . . 4-47 Create a Subsystem . . . . 4-49 Subsystem Advantages . . . 4-49 Ways to Create a Subsystem . . . 4-49 Create a Subsystem in a Subsystem Block . . . 4-50 Create a Subsystem from Selected Blocks . . . 4-51 Create a Subsystem Using Context Options . . . 4-52 Configure a Subsystem . . . . 4-54 Subsystem Execution . . . 4-54 Label Subsystem Ports . . . 4-54 Control Access to Subsystems . . . 4-54 Control Subsystem Behavior with Callbacks . . . 4-55 Navigate Subsystems in the Model Hierarchy . . . . 4-56 Open a Subsystem . . . 4-56 Preview Contents of a Subsystem . . . 4-59 Subsystem Expansion . . . . 4-60 What Is Subsystem Expansion? . . . 4-60 Why Expand a Subsystem? . . . 4-61 Subsystems That You Can Expand . . . 4-62 Results of Expanding a Subsystem . . . 4-63 Data Stores . . . 4-64 Expand Subsystem Contents . . . . 4-65 Expand a Subsystem . . . 4-65 Expand a Subsystem from the Command Line . . . 4-66 Use Control Flow Logic . . . . 4-67 Equivalent C Language Statements . . . 4-67 Conditional Control Flow Logic . . . 4-67 While and For Loops . . . 4-70 Callbacks for Customized Model Behavior . . . . 4-76 Model, Block, and Port Callbacks . . . 4-76 What You Can Do with Callbacks . . . 4-76 Avoid run Commands in Callback Code . . . 4-77 See Also . . . 4-77

(13)

Model Callbacks . . . . 4-78 Create Model Callbacks . . . 4-78 View Model Callbacks . . . 4-79 Model Callback Parameters . . . 4-80 Block Callbacks . . . . 4-83 Create Block Callbacks . . . 4-83 Block Callback Parameters . . . 4-83 Port Callbacks . . . . 4-90 Callback Tracing . . . . 4-91 Model Workspaces . . . . 4-92

Model Workspace Differences from MATLAB

Workspace . . . 4-92 Troubleshooting Memory Issues . . . 4-93 Simulink.ModelWorkspace Data Object Class . . . 4-93 Change Model Workspace Data . . . 4-94 Specify Data Sources . . . 4-96 Symbol Resolution . . . . 4-101 Symbols . . . 4-101 Symbol Resolution Process . . . 4-101 Numeric Values with Symbols . . . 4-102 Other Values with Symbols . . . 4-103 Limit Signal Resolution . . . 4-103 Explicit and Implicit Symbol Resolution . . . 4-104 Manage Model Versions . . . . 4-106 How Simulink Helps You Manage Model Versions . . . 4-106 Model File Change Notification . . . 4-107 Specify the Current User . . . 4-108 Manage Model Properties . . . 4-109 Log Comments History . . . 4-117 Version Information Properties . . . 4-119 Model Discretizer . . . . 4-121 What Is the Model Discretizer? . . . 4-121 Requirements . . . 4-121 Discretize a Model with the Model Discretizer . . . 4-122 View the Discretized Model . . . 4-130 Discretize Blocks from the Simulink Model . . . 4-133

(14)

Discretize a Model with the sldiscmdl Function . . . 4-143

Model Advisor

5

Consulting the Model Advisor . . . . 5-2 Model Advisor Overview . . . 5-2 Start the Model Advisor . . . 5-2 Model Advisor Window . . . 5-4 Model Advisor Dashboard . . . 5-7 More Information About Checking Your Model . . . 5-8 Selecting Model Checks . . . . 5-10 Check Support for Libraries . . . 5-10 Checks Triggering an Update Diagram . . . 5-10 Model Advisor Limitations . . . . 5-11 Select and Run Model Checks . . . . 5-12 Save Model Analysis Time . . . . 5-16 Run Model Checks in Background . . . . 5-18 Run Model Checks Programmatically . . . . 5-19 Address Model Check Results . . . . 5-20 Highlight Model Check Results . . . 5-20 Fix a Model Check Warning or Failure . . . 5-22 Revert Changes . . . 5-23 View and Save Model Advisor Reports . . . . 5-26 View Model Advisor Reports . . . 5-26 Save Model Advisor Reports . . . 5-27

(15)

Upgrade Advisor

6

Consult the Upgrade Advisor . . . . 6-2

Working with Sample Times

7

What Is Sample Time? . . . . 7-2 Specify Sample Time . . . . 7-3 Designate Sample Times . . . 7-3 Specify Block-Based Sample Times Interactively . . . 7-5 Specify Port-Based Sample Times Interactively . . . 7-6 Specify Block-Based Sample Times Programmatically . . 7-7 Specify Port-Based Sample Times Programmatically . . . 7-7 Access Sample Time Information Programmatically . . . 7-8 Specify Sample Times for a Custom Block . . . 7-8 Determining Sample Time Units . . . 7-8 Change the Sample Time After Simulation Start Time . 7-8 View Sample Time Information . . . . 7-9 View Sample Time Display . . . 7-9 Sample Time Legend . . . 7-10 Print Sample Time Information . . . . 7-13 Types of Sample Time . . . . 7-14 Discrete Sample Time . . . 7-14 Continuous Sample Time . . . 7-15 Fixed-in-Minor-Step . . . 7-15 Inherited Sample Time . . . 7-15 Constant Sample Time . . . 7-16 Variable Sample Time . . . 7-17 Triggered Sample Time . . . 7-18 Asynchronous Sample Time . . . 7-18 Blocks for Which Sample Time Is Not Recommended . 7-19 Best Practice to Model Sample Times . . . 7-19

(16)

Appropriate Blocks for the Sample Time Parameter . . 7-20 Specify Sample Time in Blocks Where Hidden . . . 7-20 Block Compiled Sample Time . . . . 7-21 Sample Times in Subsystems . . . . 7-24 Sample Times in Systems . . . . 7-26 Purely Discrete Systems . . . 7-26 Hybrid Systems . . . 7-28 Resolve Rate Transitions . . . . 7-32 How Propagation Affects Inherited Sample Times . . . 7-33 Process for Sample Time Propagation . . . 7-33 Simulink Rules for Assigning Sample Times . . . 7-33 Backpropagation in Sample Times . . . . 7-35

Referencing a Model

8

Overview of Model Referencing . . . . 8-2 About Model Referencing . . . 8-2 Referenced Model Advantages . . . 8-5 Masking Model Blocks . . . 8-6 Models That Use Model Referencing . . . 8-6 Model Referencing Resources . . . 8-7 Create a Model Reference . . . . 8-8 Subsystem to Model Reference Conversion . . . . 8-11 When to Convert to Model Referencing . . . 8-11 Subsystems That You Can Convert . . . 8-11 Conversion Process . . . 8-12 Conversion Checking . . . 8-13 Conversion Results . . . 8-14 Conversion Report . . . 8-15

(17)

Convert a Subsystem to a Referenced Model . . . . 8-16 Determine Whether to Convert the Subsystem . . . 8-16 Update the Model Before Converting the Subsystem . . 8-16 Run the Model Reference Conversion Advisor . . . 8-20 Compare Simulation Results Before and After

Conversion . . . 8-20 Revert the Conversion Results . . . 8-22 Integrate the Referenced Model into the Parent Model 8-23 Sample Time Consistency . . . . 8-24 Troubleshooting . . . 8-24 Inherit Sample Times . . . . 8-25 How Sample-Time Inheritance Works for Model Blocks 8-25 Conditions for Inheriting Sample Times . . . 8-25 Determining Sample Time of a Referenced Model . . . . 8-26 Blocks That Depend on Absolute Time . . . 8-26 Blocks Whose Outputs Depend on Inherited Sample

Time . . . 8-27 Referenced Model Simulation Modes . . . . 8-29 Simulation Modes for Referenced Models . . . 8-29 Specify the Simulation Mode . . . 8-31 Mixing Simulation Modes . . . 8-31 Using Normal Mode for Multiple Instances of Referenced

Models . . . 8-33 Accelerating a Freestanding or Top Model . . . 8-40 View a Model Reference Hierarchy . . . . 8-42 Display Version Numbers . . . 8-42 Model Reference Simulation Targets . . . . 8-44 Simulation Targets . . . 8-44 Build Simulation Targets . . . 8-45 Simulation Target Output File Control . . . 8-46 Reduce Update Time for Referenced Models . . . 8-48 Simulink Model Referencing Requirements . . . . 8-53 About Model Referencing Requirements . . . 8-53 Name Length Requirement . . . 8-53 Configuration Parameter Requirements . . . 8-53 Model Structure Requirements . . . 8-57

(18)

Parameterize Model References . . . . 8-59 Introduction . . . 8-59 Global Nontunable Parameters . . . 8-59 Global Tunable Parameters . . . 8-60 Using Model Arguments . . . 8-60 Conditional Referenced Models . . . . 8-66 Kinds of Conditional Referenced Models . . . 8-66 Working with Conditional Referenced Models . . . 8-67 Create Conditional Models . . . 8-67 Reference Conditional Models . . . 8-69 Simulate Conditional Models . . . 8-70 Generate Code for Conditional Models . . . 8-71 Requirements for Conditional Models . . . 8-71 Protected Model . . . . 8-73 Use Protected Model in Simulation . . . . 8-75 Protected Model Web View . . . 8-76 Refresh Model Blocks . . . . 8-77 S-Functions with Model Referencing . . . . 8-78 S-Function Support for Model Referencing . . . 8-78 Sample Times . . . 8-78 S-Functions with Accelerator Mode Referenced Models 8-79 Using C S-Functions in Normal Mode Referenced

Models . . . 8-79 Protected Models . . . 8-80 Simulink Coder Considerations . . . 8-80 Buses in Referenced Models . . . . 8-81 Signal Logging in Referenced Models . . . . 8-82 Model Referencing Limitations . . . . 8-83 Introduction . . . 8-83 Limitations on All Model Referencing . . . 8-83 Limitations on Normal Mode Referenced Models . . . 8-86 Limitations on Accelerator Mode Referenced Models . . 8-86 Limitations on Rapid Accelerator Mode Referenced

Models . . . 8-89

(19)

Certain Diagnostic Configuration Parameters Ignored for Models Referenced in Accelerator Mode . . . 8-89 Limitations on SIL and PIL Mode Referenced Models . 8-90 Configuration Parameters Changed During Code

Generation . . . 8-90

Create Conditional Subsystems

9

Conditional Subsystems . . . . 9-2 Export-Function Models . . . . 9-4 About Export-Function Models . . . 9-4 Requirements for Export-Function Models . . . 9-5 Specifying periodic sample time on function-call root-level

Inport blocks . . . 9-6 Execution Order for Function-Call Root-level Inport

Blocks . . . 9-7 Workflows for Export-Function Models . . . 9-11 Nested Export-Function Models . . . 9-15 Comparison between Export-Function Models and Models

with Asynchronous Function-Call Inputs . . . 9-16 Create an Enabled Subsystem . . . . 9-17 What Are Enabled Subsystems? . . . 9-17 Create an Enabled Subsystem . . . 9-18 Blocks an Enabled Subsystem Can Contain . . . 9-20 Use Blocks with Constant Sample Times in Enabled

Subsystems . . . 9-23 Conditionally Reset Block States in a Subsystem . . . . 9-27 Behavior of Resettable Subsystems . . . 9-27 Comparison of Resettable Subsystems and Enabled

Subsystems . . . 9-30 Create a Triggered Subsystem . . . . 9-34 What Are Triggered Subsystems? . . . 9-34 Using Model Referencing Instead of a Triggered

Subsystem . . . 9-36 Creating a Triggered Subsystem . . . 9-36

(20)

Blocks That a Triggered Subsystem Can Contain . . . . 9-37 Create an Action Subsystem . . . . 9-38 What Are Action Subsystems? . . . 9-38 Set States when an Action Subsystem Executes . . . 9-39 Create a Triggered and Enabled Subsystem . . . . 9-41 What Are Triggered and Enabled Subsystems? . . . 9-41 Creating a Triggered and Enabled Subsystem . . . 9-42 A Sample Triggered and Enabled Subsystem . . . 9-42 Creating Alternately Executing Subsystems . . . 9-43 Create a Function-Call Subsystem . . . . 9-46 What is a Function-Call Subsystem? . . . 9-46 Creating Function-Call Subsystems . . . 9-46 Sample Time Propagation in Function-Call Subsystems 9-46 Conditional Execution Behavior . . . . 9-48 What Is Conditional Execution Behavior? . . . 9-48 Propagating Execution Contexts . . . 9-50 Behavior of Switch Blocks . . . 9-51 Displaying Execution Contexts . . . 9-51 Disabling Conditional Execution Behavior . . . 9-52 Displaying Execution Context Bars . . . 9-53 Conditional Subsystem Output Initialization . . . . 9-54

Why Initialize Conditional Subsystem Output with

Explicit Values? . . . 9-54 Initialization Mode . . . 9-54 When to Use Simplified Initialization . . . 9-55 Simplified Mode Behavior and Requirements . . . 9-56 When to Use Classic Initialization . . . 9-57 Specify or Inherit Conditional Subsystem Initial

Values . . . . 9-58 Inherit Initial Values from the Input Signal . . . 9-58 Explicitly Specify an Initial Value . . . 9-59 Setting Output Values When the Conditional Subsystem

Is Disabled . . . 9-60 Set Initialization Mode to Simplified or Classic . . . . . 9-61 Convert from Classic to Simplified Initialization Mode 9-62

(21)

Address Classic Mode Issues by Using Simplified

Mode . . . . 9-63 Classic Mode Issues . . . 9-63 Identity Transformation Can Change Model Behavior . 9-64 Discrete-Time Integrator or S-Function Block Can Produce

Inconsistent Output . . . 9-66 Sorted Order Can Affect Merge Block Output . . . 9-68 Functions and Function Callers . . . . 9-76 What Are Functions in Simulink? . . . 9-76 What Are Function Callers in Simulink? . . . 9-76 Reusable Logic with Functions . . . 9-77 Shared Resources with Functions . . . 9-78 Diagnostic Messaging with Functions . . . 9-78 How a Function Caller Identifies a Function . . . 9-79 Reasons to Use a Simulink Function Block . . . 9-79 When Not to Use a Simulink Function Block . . . 9-80 Export Function Rules with Functions and Function

Callers . . . 9-80 Calling a Function from Multiple Sites . . . 9-81 Connect Function Caller Block to Simulink Function

Block . . . 9-83 Diagnostics Using a Client-Server Architecture . . . . . 9-87 Client-Server Architecture . . . 9-87 Modifier Pattern . . . 9-89 Observer Pattern . . . 9-91

Modeling Variant Systems

10

What Is a Variant? . . . . 10-2 Mapping Inports and Outports of Variant Choices . . . . 10-2 Switch Between Variant Choices . . . . 10-4 Default Variant Specification . . . 10-4 Variant Control Specification . . . 10-4 Operators and Operands in Variant Condition

Expressions . . . 10-4 Select Variant Control Specification . . . 10-6

(22)

Convert Variant Control Variables into

Simulink.Parameter Objects . . . 10-6 Workflow for Implementing Variants . . . . 10-9 Create, Export, and Reuse Variant Controls . . . . 10-10 Create and Export Variant Controls . . . 10-10 Reuse Variant Conditions . . . 10-10 Enumerated Types as Variant Controls . . . 10-11 Define, Configure, and Activate Variant Choices . . . 10-12 Represent Variant Choices . . . 10-12 Include Simulink Model as Variant Choice . . . 10-16 Configure Variant Activation Conditions . . . 10-18 Set Up Model Variants . . . . 10-20 Configure the Model Variants Block . . . 10-21 Disable and Enable Model Variants . . . 10-23 Parameterize Model Variants . . . 10-24 Additional Examples . . . 10-24 Convert Subsystem Blocks to Variant Subsystem

Blocks . . . . 10-25 Set and Open Active Variants . . . . 10-26 Set Default Variant . . . 10-26 Set and Open Active Variant . . . 10-26 Ignore Variant Choices . . . 10-27 Open Active Variant . . . 10-27 Variant Management . . . . 10-29 Variant Manager . . . 10-29 Considerations in Model Hierarchy Validation . . . 10-30 Add and Validate Variant Configurations . . . . 10-31 Import Control Variables to Variant Configuration . 10-35 Define Constraints and Export Variant

Configurations . . . . 10-39

(23)

Exploring, Searching, and Browsing Models

11

Model Explorer Overview . . . . 11-2 What You Can Do Using the Model Explorer . . . 11-2 Opening the Model Explorer . . . 11-2 Model Explorer Components . . . 11-3 The Main Toolbar . . . 11-4 Adding Objects . . . 11-4 Customizing the Model Explorer Interface . . . 11-5 Basic Steps for Using the Model Explorer . . . 11-6 Focusing on Specific Elements of a Model or Chart . . . 11-7 Model Explorer: Model Hierarchy Pane . . . . 11-9 What You Can Do with the Model Hierarchy Pane . . . 11-9 Simulink Root . . . 11-10 Base Workspace . . . 11-10 Configuration Preferences . . . 11-11 Model Nodes . . . 11-11 Displaying Partial or Whole Model Hierarchy

Contents . . . 11-12 Displaying Linked Library Subsystems . . . 11-13 Displaying Masked Subsystems . . . 11-13 Linked Library and Masked Subsystems . . . 11-13 Displaying Node Contents . . . 11-14 Navigating to the Block Diagram . . . 11-14 Working with Configuration Sets . . . 11-14 Expanding Model References . . . 11-14 Cutting, Copying, and Pasting Objects . . . 11-17 Model Explorer: Contents Pane . . . . 11-19 Contents Pane Tabs . . . 11-19 Data Displayed in the Contents Pane . . . 11-21 Link to the Currently Selected Node . . . 11-22 Horizontal Scrolling in the Object Property Table . . . 11-22 Working with the Contents Pane . . . 11-23 Editing Object Properties . . . 11-24 Control Model Explorer Contents Using Views . . . . . 11-25 Using Views . . . 11-25 Customizing Views . . . 11-28 Managing Views . . . 11-29

(24)

Organize Data Display in Model Explorer . . . . 11-33 Layout Options . . . 11-33 Sorting Column Contents . . . 11-33 Grouping by a Property . . . 11-34 Changing the Order of Property Columns . . . 11-37 Adding Property Columns . . . 11-38 Hiding or Removing Property Columns . . . 11-39 Marking Nonexistent Properties . . . 11-41 Filter Objects in the Model Explorer . . . . 11-42 Controlling the Set of Objects to Display . . . 11-42 Using the Row Filter Option . . . 11-42 Filtering Contents . . . 11-44 Workspace Variables in Model Explorer . . . . 11-47 Finding Variables That Are Used by a Model or Block 11-47 Finding Blocks That Use a Specific Variable . . . 11-50 Finding Unused Workspace Variables . . . 11-51 Editing Workspace Variables . . . 11-53 Rename Variables . . . 11-54 Compare Duplicate Workspace Variables . . . 11-56 Export Workspace Variables . . . 11-57 Importing Workspace Variables . . . 11-59 Search Using Model Explorer . . . . 11-60 Searching in the Model Explorer . . . 11-60 The Search Bar . . . 11-60 Show and Hide the Search Bar . . . 11-61 Search Bar Controls . . . 11-61 Search Options . . . 11-63 Run a Search . . . 11-65 Refine a Search . . . 11-65 Model Explorer: Property Dialog Pane . . . . 11-66 What You Can Do with the Dialog Pane . . . 11-66 Showing and Hiding the Dialog Pane . . . 11-66 Editing Properties in the Dialog Pane . . . 11-66 Locate Simulink Objects Using Find . . . . 11-69 Locate Stateflow Objects Using Find . . . . 11-71

(25)

Model Browser . . . . 11-73 About the Model Browser . . . 11-73 Navigating with the Mouse . . . 11-74 Navigating with the Keyboard . . . 11-75 Showing Library Links . . . 11-75 Showing Masked Subsystems . . . 11-75 Model Dependency Viewer . . . . 11-76 About Model Dependency Views . . . 11-76 Opening the Model Dependency Viewer . . . 11-81 Manipulating a Dependency View . . . 11-82 Browsing Dependencies . . . 11-87 Saving a Dependency View . . . 11-87 Printing a Dependency View . . . 11-87 View Linked Requirements in Models and Blocks . . . 11-88 Requirements Traceability in Simulink . . . 11-88 Highlight Requirements in a Model . . . 11-88 View Information About a Requirements Link . . . 11-91 Navigate to Requirements from a Model . . . 11-92 Filter Requirements in a Model . . . 11-93 Trace Connections Using Interface Display . . . . 11-96 How Interface Display Works . . . 11-96 Trace Connections in a Subsystem . . . 11-96

Managing Model Configurations

12

About Model Configurations . . . . 12-2 Multiple Configuration Sets in a Model . . . . 12-3 Share a Configuration for Multiple Models . . . . 12-4 Share a Configuration Across Referenced Models . . . . 12-6 Manage a Configuration Set . . . . 12-11 Create a Configuration Set in a Model . . . 12-11 Create a Configuration Set in the Base Workspace . . 12-11

(26)

Open a Configuration Set in the Configuration Parameters Dialog Box . . . 12-12 Activate a Configuration Set . . . 12-13 Set Values in a Configuration Set . . . 12-13 Copy, Delete, and Move a Configuration Set . . . 12-13 Save a Configuration Set . . . 12-14 Load a Saved Configuration Set . . . 12-15 Copy Configuration Set Components . . . 12-15 Manage a Configuration Reference . . . . 12-17 Create and Attach a Configuration Reference . . . 12-17 Resolve a Configuration Reference . . . 12-18 Activate a Configuration Reference . . . 12-20 Manage Configuration Reference Across Referenced

Models . . . 12-21 Change Parameter Values in a Referenced Configuration

Set . . . 12-22 Save a Referenced Configuration Set . . . 12-22 Load a Saved Referenced Configuration Set . . . 12-23 Why is the Build Button Not Available for a Configuration

Reference? . . . 12-23 About Configuration Sets . . . . 12-25 What Is a Configuration Set? . . . 12-25 What Is a Freestanding Configuration Set? . . . 12-26 Model Configuration Preferences . . . 12-27 About Configuration References . . . . 12-28 What Is a Configuration Reference? . . . 12-28 Why Use Configuration References? . . . 12-28 Unresolved Configuration References . . . 12-29 Configuration Reference Limitations . . . 12-29 Configuration References for Models with Older

Simulation Target Settings . . . 12-30 Model Configuration Command Line Interface . . . . . 12-32 Overview . . . 12-32 Load and Activate a Configuration Set at the Command

Line . . . 12-33 Save a Configuration Set at the Command Line . . . . 12-34 Create a Freestanding Configuration Set at the Command

Line . . . 12-34 Create and Attach a Configuration Reference at the

Command Line . . . 12-35

(27)

Attach a Configuration Reference to Multiple Models at

the Command Line . . . 12-36 Get Values from a Referenced Configuration Set . . . . 12-37 Change Values in a Referenced Configuration Set . . . 12-37 Obtain a Configuration Reference Handle . . . 12-38 Use refresh When Replacing a Referenced Configuration

Set . . . 12-38

Configuring Models for Targets with Multicore Processors

13

How Simulink Solves Parallel and Multicore Processing Problems . . . . 13-2

Basics of Concurrent Execution . . . 13-2 Model Parallel Computations . . . 13-4 Handle Problems that Arise from Parallelism . . . 13-7 Handle Data Transfers . . . 13-7 Algebraic Loops . . . 13-8 Supported Multicore Targets . . . 13-9 Supported Heterogeneous Targets . . . 13-9 Helpful Terms . . . 13-10 Simulation Limitations . . . 13-11 Modeling Process for Concurrent Execution . . . . 13-12 Configure Your Model . . . . 13-13 Customize Concurrent Execution Settings . . . . 13-15 Configuring Data Transfer Communications . . . 13-15 Select Target Architecture . . . 13-17 Configuring Periodic Triggers and Tasks . . . 13-19 Configuring Aperiodic Triggers and Tasks . . . 13-20 Map Blocks to Tasks, Triggers, and Nodes . . . 13-22 Interpret Simulation Results . . . . 13-24 Introduction . . . 13-24 Baseline Configuration . . . 13-24 Sample Configured Model with Multiple Target Tasks 13-25

(28)

Build and Download to a Multicore Target . . . . 13-29 Generating Code . . . 13-29 Customize the Generated C Code . . . 13-30 Define a Custom Architecture File . . . 13-30 Native Threads Example . . . 13-33 Profile and Evaluate . . . 13-35 Generate Profile Report . . . 13-36 Concurrent Execution Models . . . . 13-40 Command-Line Interface for Concurrent Execution . 13-41 Map Blocks to Tasks . . . 13-41

Modeling Best Practices

14

General Considerations when Building Simulink

Models . . . . 14-2 Avoiding Invalid Loops . . . 14-2 Shadowed Files . . . 14-4 Model Building Tips . . . 14-6 Model a Continuous System . . . . 14-8 Best-Form Mathematical Models . . . . 14-11 Series RLC Example . . . 14-11 Solving Series RLC Using Resistor Voltage . . . 14-12 Solving Series RLC Using Inductor Voltage . . . 14-13 Model a Simple Equation . . . . 14-15 Model Differential Algebraic Equations . . . . 14-17 Overview of Robertson Reaction Example . . . 14-17 Simulink Model from ODE Equations . . . 14-17 Simulink Model from DAE Equations . . . 14-20 Simulink Model from DAE Equations Using Algebraic

Constraint Block . . . 14-23 Componentization Guidelines . . . . 14-28 Componentization . . . 14-28

(29)

Componentization Techniques . . . 14-28 General Componentization Guidelines . . . 14-29 Summary of Componentization Techniques . . . 14-30 Subsystems Summary . . . 14-32 Libraries Summary . . . 14-35 Model Referencing Summary . . . 14-39 Modeling Complex Logic . . . . 14-45 Modeling Physical Systems . . . . 14-46 Modeling Signal Processing Systems . . . . 14-47

Simulink Project Setup

15

Organize Large Modeling Projects . . . . 15-2 What Are Simulink Projects? . . . . 15-3 Try Simulink Project Tools with the Airframe

Project . . . . 15-5 Explore the Airframe Project . . . 15-5 Set Up Project Files and Open Simulink Project . . . 15-6 View, Search, and Sort Project Files . . . 15-6 Understand Project Startup and Shutdown Tasks . . . . 15-8 Create a Startup Shortcut . . . 15-10 Open and Run Frequently Used Files . . . 15-10 Review Changes in Modified Files . . . 15-11 Run Project Integrity Checks . . . 15-13 Run Dependency Analysis . . . 15-13 Commit Modified Files . . . 15-16 View Project and Source Control Information . . . 15-17 Create a New Project to Manage Existing Files . . . . . 15-19 Add Files to the Project . . . . 15-23 Create a New Project from an Archived Project . . . . 15-25

(30)

Create a New Project Using Templates . . . . 15-26 Use Project Templates from R2014a or Before . . . . 15-30 Open Recent Projects . . . . 15-31 Change the Project Name, Root, Description, and

Startup Folder . . . . 15-32 Specify Project Path . . . . 15-34 What Can You Do With Project Shortcuts? . . . . 15-36 Automate Startup Tasks with Shortcuts . . . . 15-37 Automate Shutdown Tasks with Shortcuts . . . . 15-40 Create Shortcuts to Frequent Tasks . . . . 15-42 Create Shortcuts . . . 15-42 Group Shortcuts . . . 15-43 Annotate Shortcuts to Use Meaningful Names . . . 15-44 Use Shortcuts to Find and Run Frequent Tasks . . . . 15-46 Using Templates to Create Standard Project Settings 15-49 Create a Template from the Current Project . . . . 15-50 Create a Template from a Project Under Version

Control . . . . 15-51 Edit a Template . . . . 15-52 Explore the Example Templates . . . . 15-53

Simulink Project File Management

16

Group and Sort File Views . . . . 16-2

(31)

Search and Filter File Views . . . . 16-4 Work with Project Files . . . . 16-6 Move Project Files . . . . 16-9 Back Out Changes . . . . 16-10 Upgrade Model Files to SLX and Preserve Revision

History . . . . 16-11 Project Tools for Migrating Model Files to SLX . . . 16-11 Upgrade the Model and Commit the Changes . . . 16-11 Verify Changes After Upgrade to SLX . . . 16-14 Create Labels . . . . 16-16 Add Labels to Files . . . . 16-17 View and Edit Label Data . . . . 16-18 Automate Project Management Tasks . . . . 16-20 Manipulate a Simulink Project at the Command Line 16-20 Get Simulink Project at the Command Line . . . 16-20 Find Project Commands . . . 16-21 Examine Project Files . . . 16-21 Create New Category of Project Labels . . . 16-22 Define a New Label . . . 16-23 Label a Project File . . . 16-23 Attach Data to a Label . . . 16-23 Attach New Label with Numeric Data Type . . . 16-24 Query Shortcuts . . . 16-24 Close Project . . . 16-26 More Project API Examples . . . 16-26 Create a Batch Function . . . . 16-27 Create Shortcuts to Batch Job Functions . . . . 16-28 Run a Simulink Project Batch Job . . . . 16-29 Sharing Simulink Projects . . . . 16-31 Share Project by Email . . . . 16-33

(32)

Share Project as a MATLAB Toolbox . . . . 16-34 Share Project on GitHub . . . . 16-35 Archive Projects in Zip Files . . . . 16-37

Simulink Project Dependency Analysis

17

What Is Dependency Analysis? . . . . 17-2 Project Dependency Analysis . . . 17-2 Model Dependency Analysis . . . 17-2 Choose Files and Run Dependency Analysis . . . . 17-3 Check Dependencies Results and Resolve Problems . . 17-6 Perform Impact Analysis . . . . 17-11 About Impact Analysis . . . 17-11 Perform Dependency Analysis . . . 17-12 Analyze the Impact of Selected Files . . . 17-13 Explore Impact Graph . . . 17-15 Export Impact Results . . . 17-19 Find Requirements Documents in a Project . . . . 17-21 Save, Open, and Compare Dependency Analysis

Results . . . . 17-23 Analyze Model Dependencies . . . . 17-24 What Are Model Dependencies? . . . 17-24 Generate Manifests . . . 17-25 Command-Line Dependency Analysis . . . 17-30 Edit Manifests . . . 17-33 Compare Manifests . . . 17-36 Export Files in a Manifest . . . 17-37 Scope of Dependency Analysis . . . 17-39 Best Practices for Dependency Analysis . . . 17-42 Use the Model Manifest Report . . . 17-43

(33)

Simulink Project Source Control

18

About Source Control with Projects . . . . 18-2 Add a Project to Source Control . . . . 18-3 Add a Project to Git Source Control . . . 18-3 Add a Project to SVN Source Control . . . 18-4 Register Model Files with Source Control Tools . . . . . 18-7 Set Up SVN Source Control . . . . 18-8

Set Up SVN Integration Provided with Simulink

Project . . . 18-8 Set Up SVN Integration for SVN Version Already

Installed . . . 18-9 Set Up SVN Integration for SVN Version Not Yet Provided

with Simulink Project . . . 18-9 Register Model Files with Subversion . . . 18-10 Enforce SVN Locking Model Files Before Editing . . . 18-13 Share a Subversion Repository . . . 18-14 Set Up Git Source Control . . . . 18-16 About Git Source Control . . . 18-16 Use Git Source Control in Simulink Project . . . 18-17 Install Command-Line Git Client . . . 18-18 Register Model Files with Git . . . 18-19 Disable Source Control . . . . 18-21 Change Source Control . . . . 18-22 Write a Source Control Adapter with the SDK . . . . 18-23 Retrieve a Working Copy of a Project from Source

Control . . . . 18-24 Tag and Retrieve Versions of Project Files . . . . 18-28 Refresh Status of Project Files . . . . 18-30 Check for Modifications . . . . 18-34

(34)

Update Revisions of Project Files . . . . 18-35 Update Revisions with SVN . . . 18-35 Update Revisions with Git . . . 18-36 Update Selected Files . . . 18-36 Get File Locks . . . . 18-37 View Modified Files . . . . 18-40 Project Definition Files . . . 18-41 Review Changes . . . . 18-42 Precommit Actions . . . . 18-44 Commit Modified Files to Source Control . . . . 18-46 Revert Changes . . . . 18-48 Revert Local Changes . . . 18-48 Revert a File to a Specified Revision . . . 18-48 Revert the Project to a Specified Revision . . . 18-49 Branch and Merge Files with Git . . . . 18-50 Create a Branch . . . 18-50 Switch Branch . . . 18-52 Merge Branches . . . 18-52 Revert to Head . . . 18-53 Delete Branches . . . 18-53 Push and Fetch Files with Git . . . . 18-54 Push . . . 18-54 Fetch . . . 18-55 Push Empty Folders . . . 18-55 Resolve Conflicts . . . . 18-57 Resolve Conflicts . . . 18-57 Merge Text Files . . . 18-59 Merge Models . . . 18-60 Extract Conflict Markers . . . 18-60 Work with Derived Files in Projects . . . . 18-62

(35)

Large-Scale Modeling

19

Design Partitioning . . . . 19-2 When to Partition a Design . . . 19-2 When Not to Partition a Design . . . 19-3 Plan for Componentization in Model Design . . . 19-4 Guidelines for Component Size and Functionality . . . . 19-4 Choose Components for Team-Based Development . . . 19-8 Partition an Existing Design . . . 19-10 Manage Components Using Libraries . . . 19-11 Interface Design . . . . 19-13 Why Interface Definitions Are Important . . . 19-13 Recommendations for Interface Design . . . 19-13 Partitioning Data . . . 19-15 Configuration Management . . . . 19-17 Manage Designs Using Source Control . . . 19-17 Determine the Files Used by a Component . . . 19-18 Manage Model Versions . . . 19-18 Create Configurations . . . 19-19

Power Window Example

20

Power Window . . . . 20-2 Study Power Windows . . . 20-2 MathWorks Software Used in This Example . . . 20-3 Quantitative Requirements . . . 20-4 Simulink Power Window Controller in Simulink

Project . . . 20-13 Simulink Power Window Controller . . . 20-15 Create Model Using Model-Based Design . . . 20-31 Automatic Code Generation for Control Subsystem . . 20-53 References . . . 20-54

(36)

Simulating Dynamic Systems

Running Simulations

21

Simulation Basics . . . . 21-2 Control Execution of a Simulation . . . . 21-3 Start a Simulation . . . 21-3 Pause or Stop a Simulation . . . 21-4 Use Blocks to Stop or Pause a Simulation . . . 21-5 Specify Simulation Start and Stop Time . . . . 21-7 Choose a Solver . . . . 21-8 What Is a Solver? . . . 21-8 Choosing a Solver Type . . . 21-9 Choosing a Fixed-Step Solver . . . 21-12 Choosing a Variable-Step Solver . . . 21-15 Choosing a Jacobian Method for an Implicit Solver . . 21-21 Interact with a Running Simulation . . . . 21-28 Save and Restore Simulation State as SimState . . . . 21-29 SimState and Repetitive Simulations . . . 21-29 Information Saved in a SimState . . . 21-30 Benefits of Using SimState . . . 21-30 When You Can Save a SimState . . . 21-31 Save SimState . . . 21-31 Restore SimState . . . 21-32 Change the States of a Block Within SimState . . . 21-33 S-Functions . . . 21-33 Model Changes and SimState . . . 21-33 Limitations of SimState . . . 21-34 View Errors and Warnings . . . . 21-36 Toolbar . . . 21-38 Message Pane . . . 21-39

(37)

Systematic Diagnosis of Simulation Errors and

Warnings . . . . 21-41 Customize Simulation Messages . . . . 21-45 Display Custom Text . . . 21-45 Create Hyperlinks to Files, Folders, or Blocks . . . 21-46 Create Programmatic Hyperlinks . . . 21-46

Running a Simulation Programmatically

22

About Programmatic Simulation . . . . 22-2 Run Simulation Using the sim Command . . . . 22-3 Single-Output Syntax for the sim Command . . . 22-3 Examples of Implementing the sim Command . . . 22-4 Calling sim from Within parfor . . . 22-5 Backwards Compatible Syntax . . . 22-5 Control Simulation Using the set_param Command . . 22-7 How Using set_param to Control Simulation Works . . 22-7 set_param Syntax . . . 22-7 Update Workspace Variables Dynamically During

Simulation . . . 22-8 Check Status of Simulation . . . 22-8 Control Simulation Using Block Callbacks . . . 22-8 Run Parallel Simulations . . . . 22-10 Overview of Calling sim from Within parfor . . . 22-10 Simulink and Parallel Computing Toolbox Software . 22-14 Simulink and MATLAB Distributed Computing Server

Software . . . 22-15 sim in parfor with Normal Mode . . . 22-15 sim in parfor with Normal Mode and MATLAB

Distributed Computing Server Software . . . 22-17 sim in parfor with Rapid Accelerator Mode . . . 22-18 Workspace Access Issues . . . 22-19 Resolving Workspace Access Issues . . . 22-20 Data Concurrency Issues . . . 22-21 Resolving Data Concurrency Issues . . . 22-22

(38)

Error Handling in Simulink Using MSLException . . 22-25 Error Reporting in a Simulink Application . . . 22-25 The MSLException Class . . . 22-25 Methods of the MSLException Class . . . 22-25 Capturing Information about the Error . . . 22-25

Visualizing and Comparing Simulation Results

23

View Simulation Results . . . . 23-2 What Are Scope Blocks, Signal Viewers, Test Points and

Signal Logging? . . . 23-2 Scope Block and Scope Viewer Differences . . . 23-3 Why Use Scope Viewers Instead of Scope Blocks? . . . . 23-3 Scope Viewer Characteristics . . . . 23-5 Scope Viewer Toolbar . . . 23-5 Scope Viewer Context Menu . . . 23-6 Scope Viewer Parameters Dialog Box . . . 23-6 Parameter Settings and Performance with Scope

Viewer . . . 23-9 Scope Viewer Tasks . . . . 23-10 Attach Scope Viewer to Signal . . . 23-10 Add Signal to an Existing Scope Viewer . . . 23-13 Display a Scope Viewer . . . 23-13 Save Simulation Data With Scope Viewer . . . 23-13 Create Multiple Axes . . . 23-14 Signal Generator Tasks . . . . 23-16 Attach Signal Generator . . . 23-16 Attach and Remove Signal Generator . . . 23-16 Signal and Scope Manager . . . . 23-17 About the Signal & Scope Manager . . . 23-17 Open the Signal and Scope Manager . . . 23-18 Change Generator or Viewer Parameters . . . 23-18 Add Signals to a Scope Viewer . . . 23-18 Remove Signal Generator or Scope Viewer . . . 23-18 Viewing Test Point Data . . . 23-19

(39)

Signal Selector . . . . 23-20 About the Signal Selector . . . 23-20 Select Signals . . . 23-21 Model Hierarchy . . . 23-21 Inputs/Signals List . . . 23-21 Control Time Scope Programmatically . . . . 23-24 Use Simulink.scopes.TimeScopeConfiguration . . . 23-24 Time Scope Configuration Parameters . . . 23-25 Migrate Scope To Time Scope . . . . 23-26 Why Migrate Scope Blocks to Time Scope blocks? . . . 23-26 Use Upgrade Advisor to Migrate Scopes . . . 23-26 Use Toolbar Button to Migrate Scopes . . . 23-27 Go Back to Scope . . . 23-27

Inspecting and Comparing Logged Signal Data

24

Methods for Viewing Simulation Results . . . . 24-2 View a Signal . . . 24-2 Inspect and Compare Signal Data . . . 24-2 Save Simulation Data to the Workspace . . . 24-2 Inspect Signal Data with Simulation Data Inspector . 24-3 Open the Simulation Data Inspector . . . . 24-5 Why Is the Simulation Data Inspector Empty? . . . 24-5 Stream Data to the Simulation Data Inspector . . . . 24-7 Use Signal Streaming to Iterate Model Design . . . 24-8 Requirements for Recording Data . . . . 24-11 Record Logged Simulation Data . . . . 24-12 Configure Model for Recording Logged Data . . . 24-12 Simulate Model and Record a Run . . . 24-13 Import Signal Data . . . . 24-15 Import Signal Data from the Base Workspace . . . 24-15

(40)

Import Signal Data from a MAT-File . . . 24-17 Save and Load Simulation Data Inspector Sessions . 24-18 Save a Session to a MAT-File . . . 24-18 Load a Saved Simulation Data Inspector Session . . . . 24-18 Inspect Signal Data . . . . 24-19 View Signal Data . . . 24-19 Explore Signal Data . . . 24-20 View Signals on Multiple Plots . . . 24-22 Compare Signal Data from Multiple Simulations . . . 24-26 Create Simulation Data Inspector Report . . . . 24-29 Export Results from the Simulation Data Inspector . 24-31 Export Data to the Base Workspace . . . 24-31 Export Data to a MAT-File . . . 24-32 How the Simulation Data Inspector Compares Time

Series Data . . . . 24-33 How the Simulation Data Inspector Applies

Tolerances . . . 24-33 How the Simulation Data Inspector Aligns Signals . . 24-34 Run Management Configuration . . . . 24-36 Append New Runs . . . 24-36 Specify a Run Naming Rule . . . 24-36 Overwrite a Run . . . 24-37 Customize the Simulation Data Inspector Interface . 24-38

Add/Remove a Column in the Runs or Comparisons

Pane . . . 24-38 View Signal and Run Properties . . . 24-41 Rename a Run . . . 24-43 Modify Grouping in Runs Pane . . . 24-43 Modify Signal Alignment for Comparisons . . . 24-45 Specify the Line Color and Style . . . 24-46 Modify Streamed Signal Properties . . . 24-47 Modify a Plot in the Simulation Data Inspector . . . 24-48 Limitations of the Simulation Data Inspector . . . . 24-50

(41)

Inspect and Compare Signal Data Programmatically 24-51 Overview . . . 24-51 Run Management . . . 24-51 Signal Management . . . 24-52 Import/Export Data . . . 24-52 Comparison Results . . . 24-53 Create a Run in the Simulation Data Inspector . . . 24-53 Compare Signal Data . . . 24-54 Compare Runs of Simulation Data . . . 24-54 Specify Signal Tolerances . . . 24-55 Record Data During Parallel Simulations . . . 24-56 Keyboard Shortcuts for the Simulation Data

Inspector . . . . 24-58 General Actions . . . 24-58 Plot Zooming . . . 24-58 Data Cursors . . . 24-58 Tune and Visualize Your Model with Dashboard

Blocks . . . . 24-60 Dashboard Blocks . . . 24-60 Open the Model and Dashboard Library . . . 24-60 Connect Parameter to a Knob . . . 24-61 View Signal Data . . . 24-61 Tune Parameters During Simulation . . . 24-62

Analyzing Simulation Results

25

Viewing Output Trajectories . . . . 25-2 Viewing and Exporting Simulation Data . . . 25-2 Using the Scope Block . . . 25-2 Using Return Variables . . . 25-2 Using the To Workspace Block . . . 25-3 Using the Simulation Data Inspector Tool . . . 25-4 Linearizing Models . . . . 25-5 About Linearizing Models . . . 25-5 Linearization with Referenced Models . . . 25-7 Linearization Using the 'v5' Algorithm . . . 25-9

(42)

Finding Steady-State Points . . . . 25-10

Improving Simulation Performance and Accuracy

26

How Optimization Techniques Improve Performance

and Accuracy . . . . 26-2 Speed Up Simulation . . . . 26-3 How Profiler Captures Performance Data . . . . 26-5 How Profiler Works . . . 26-5 Start Profiler . . . 26-7 Save Profiler Results . . . 26-10 Check and Improve Simulation Accuracy . . . . 26-11 Check Simulation Accuracy . . . 26-11 Unstable Simulation Results . . . 26-11 Inaccurate Simulation Results . . . 26-11 Modeling Techniques That Improve Performance . . . 26-13 Accelerate the Initialization Phase . . . 26-13 Reduce Model Interactivity . . . 26-14 Reduce Model Complexity . . . 26-15 Choose and Configure a Solver . . . 26-16 Save the Simulation State . . . 26-18 How Parallel Simulations Reduce Simulation Time . 26-20 Use Performance Advisor to Improve Simulation

Efficiency . . . . 26-21

(43)

Performance Advisor

27

How Performance Advisor Improves Simulation

Performance . . . . 27-2 Performance Advisor Workflow . . . . 27-3 Get Started with Performance Advisor . . . . 27-5 Prepare to Use Performance Advisor . . . 27-5 Start Performance Advisor . . . 27-5 Performance Advisor Window . . . . 27-7 Prepare a Model for Performance Advisor . . . . 27-9 Enable Data Logging for the Model . . . 27-9 Select How Performance Advisor Applies Advice . . . . 27-10 Select Validation Actions for the Advice . . . 27-10 Create a Performance Advisor Baseline Measurement 27-10 Perform a Quick Scan Diagnosis . . . . 27-13 Run Quick Scan on a Model . . . 27-13 Checks in Quick Scan Mode . . . 27-13 Run Performance Advisor . . . . 27-15 Run Performance Advisor Checks . . . 27-15 Use Performance Advisor Reports . . . . 27-18 View Performance Advisor Reports . . . 27-18 Save Performance Advisor Reports . . . 27-19 Operate on Performance Advisor Results . . . . 27-21 View Results . . . 27-21 Respond to Results . . . 27-22 Review the Actions Taken . . . 27-22 Improve vdp Model Performance . . . . 27-24 Enable Data Logging for the Model . . . 27-24 Create Baseline . . . 27-24 Select Checks and Run . . . 27-25 Review Results . . . 27-26 Apply Advice and Validate Manually . . . 27-28

(44)

Simulink Debugger

28

Introduction to the Debugger . . . . 28-2 Debugger Graphical User Interface . . . . 28-3 Displaying the Graphical Interface . . . 28-3 Toolbar . . . 28-4 Breakpoints Pane . . . 28-5 Simulation Loop Pane . . . 28-5 Outputs Pane . . . 28-7 Sorted List Pane . . . 28-7 Status Pane . . . 28-8 Debugger Command-Line Interface . . . . 28-9 Controlling the Debugger . . . 28-9 Method ID . . . 28-9 Block ID . . . 28-9 Accessing the MATLAB Workspace . . . 28-10 Debugger Online Help . . . . 28-11 Start the Simulink Debugger . . . . 28-12 Starting from a Model Window . . . 28-12 Starting from the Command Window . . . 28-12 Start a Simulation . . . . 28-14 Run a Simulation Step by Step . . . . 28-16 Introduction . . . 28-16 Block Data Output . . . 28-17 Stepping Commands . . . 28-18 Continuing a Simulation . . . 28-19 Running a Simulation Nonstop . . . 28-19 Set Breakpoints . . . . 28-20 About Breakpoints . . . 28-20 Setting Unconditional Breakpoints . . . 28-20 Setting Conditional Breakpoints . . . 28-22 Display Information About the Simulation . . . . 28-26 Display Block I/O . . . 28-26

(45)

Display Algebraic Loop Information . . . 28-28 Display System States . . . 28-28 Display Solver Information . . . 28-29 Display Information About the Model . . . . 28-31 Display Model’s Sorted Lists . . . 28-31 Display a Block . . . 28-32

Accelerating Models

29

What Is Acceleration? . . . . 29-2 How Acceleration Modes Work . . . . 29-4 Overview . . . 29-4 Normal Mode . . . 29-4 Accelerator Mode . . . 29-5 Rapid Accelerator Mode . . . 29-6 Code Regeneration in Accelerated Models . . . . 29-8 Determine If the Simulation Will Rebuild . . . 29-8 Parameter Tuning in Rapid Accelerator Mode . . . 29-8 Choosing a Simulation Mode . . . . 29-11 Simulation Mode Tradeoffs . . . 29-11 Comparing Modes . . . 29-12 Decision Tree . . . 29-14 Design Your Model for Effective Acceleration . . . . 29-17 Select Blocks for Accelerator Mode . . . 29-17 Select Blocks for Rapid Accelerator Mode . . . 29-18 Control S-Function Execution . . . 29-18 Accelerator and Rapid Accelerator Mode Data Type

Considerations . . . 29-19 Behavior of Scopes and Viewers with Rapid Accelerator

Mode . . . 29-19 Factors Inhibiting Acceleration . . . 29-20 Perform Acceleration . . . . 29-24 Customize the Build Process . . . 29-24

(46)

Run Acceleration Mode from the User Interface . . . . 29-25 Making Run-Time Changes . . . 29-26 Interact with the Acceleration Modes

Programmatically . . . . 29-28 Why Interact Programmatically? . . . 29-28 Build Accelerator Mode MEX-files . . . 29-28 Control Simulation . . . 29-28 Simulate Your Model . . . 29-29 Customize the Acceleration Build Process . . . 29-30 Run Accelerator Mode with the Simulink Debugger . 29-32

Advantages of Using Accelerator Mode with the

Debugger . . . 29-32 How to Run the Debugger . . . 29-32 When to Switch Back to Normal Mode . . . 29-32 Comparing Performance . . . . 29-34 Performance of the Simulation Modes . . . 29-34 Measure Performance . . . 29-36 How to Improve Performance in Acceleration Modes 29-38 Techniques . . . 29-38 C Compilers . . . 29-38

Managing Blocks

Working with Blocks

30

About Blocks . . . . 30-2 What Are Blocks? . . . 30-2 Block Tool Tips . . . 30-2 Virtual Blocks . . . 30-2 Techniques for Adding Blocks to a Model . . . . 30-4

(47)

Add Blocks Using Quick Insert . . . . 30-5 Add a Block . . . 30-5 Set a Key Parameter Without Opening the Block

Parameters Dialog Box . . . 30-6 Copy Blocks from a Model . . . . 30-7 Add Blocks Programmatically . . . . 30-8 Edit Blocks . . . . 30-9 Copy Blocks in a Model . . . 30-9 Copy Blocks Between Windows . . . 30-9 Move Blocks . . . 30-10 Delete Blocks . . . 30-13 Comment Blocks . . . 30-13 Set Block Properties . . . . 30-14 Block Properties Dialog Box . . . 30-14 General Block Properties . . . 30-16 Block Annotation Properties . . . 30-16 Block Callbacks . . . 30-18 Create Block Annotations Programmatically . . . 30-20 Change the Appearance of a Block . . . . 30-22 Change a Block Orientation . . . 30-22 Resize a Block . . . 30-24 Displaying Parameters Beneath a Block . . . 30-25 Drop Shadows . . . 30-25 Manipulate Block Names . . . 30-25 Specify Block Color . . . 30-27 Display Port Values for Debugging . . . . 30-28 How Displaying Port Values Helps with Debugging . . 30-28 Display Value for a Specific Port . . . 30-32 Display Port Values for a Model . . . 30-32 When No Data Is Available to Display . . . 30-32 Port Value Display Limitations . . . 30-33 Control and Display the Sorted Order . . . . 30-36 What Is Sorted Order? . . . 30-36 Display the Sorted Order . . . 30-36 Sorted Order Notation . . . 30-37 How Simulink Determines the Sorted Order . . . 30-47

Referanslar

Benzer Belgeler

In the experiments, warehouses were tested for different pick density values that generate the number of items to be picked (size of order). The locations of the items to be picked

A case of acute rheumatic fever presenting with syncope due to complete atrioventricular block.. Tam atriyoventriküler blok nedeni ile senkopla baflvuran akut romatizmal

Appearance of right bundle branch block in electrocardiograms of patients with pulmonary embo- lism as a marker for obstruction of the main pulmonary trunk. Reflexes from

.The results show WSC could increase T lymphocyte proliferation in high-dose group.In the analysis of cytokines were secreted by splenocyte by using conA — stimulating, IFN-γ which

To address whether three forms of angiostatin, K1-3, K1-4 or K1-4.5, utilized similar or distinct pathways to mediate anti-angiogenesis, we adopted an adenoviral expression system

Bu çal›flmada ise köken olarak Türk olan ya da farkl› bir etnik yap›ya mensup bulunan ya- banc› uyruklu ö¤rencilerin stresle bafla ç›kma tutumlar›n›n, problem

Taha Toros

Bilindi~i gibi Osmanl~~ Devleti'nde askeri veya reayadan herkesin herhangi bir devlet da- iresinden ba~ka, padi~aha ve en üst icra ve kaza organ~~ olan Divân-~~ Hümâyün'a dahi arzuhal