| Contents | Index |
• Working with Block Parameters
• Working with Block Libraries
• Using the MATLAB Function Block
• Introduction to MATLAB Function Blocks
• Creating an Example Model That Uses a MATLAB Function Block
• Debugging a MATLAB Function Block
• MATLAB Function Block Editor
• Working with MATLAB Function Reports
Parameter Arguments in MATLAB Function Block Functions
• Resolving Signal Objects for Output Data
Eliminating Warnings for Implicit Signal Resolution in the Model
Disabling Implicit Signal Resolution for a MATLAB Function Block
Forcing Explicit Signal Resolution for an Output Data Signal
• Working with Structures and Bus Signals
About Structures in MATLAB Function Blocks
Example of Structures in a MATLAB Function Block
How Structure Inputs and Outputs Interface with Bus Signals
Rules for Defining Structures in MATLAB Function Blocks
Workflow for Creating Structures in MATLAB Function Blocks
Indexing Substructures and Fields
Assigning Values to Structures and Fields
Working with Structure Parameters in MATLAB Function Blocks
Limitations of Structures and Buses in MATLAB Function Blocks
• Using Variable-Size Data in MATLAB Function Blocks
How MATLAB Function Blocks Implement Variable-Size Data
Enabling Support for Variable-Size Data
Declaring Variable-Size Inputs and Outputs
Declaring Variable-Size Data Locally
Simple Example: Defining and Using Variable-Size Data in MATLAB Function Blocks
• Using Enumerated Data in MATLAB Function Blocks
Enumerated Data in MATLAB Function Blocks
Simple Example: Defining and Using Enumerated Types in MATLAB Function Blocks
Using Enumerated Data in MATLAB Function Blocks
How to Define Enumerated Data Types for MATLAB Function Blocks
How to Add Enumerated Data to MATLAB Function Blocks
How to Instantiate Enumerated Data in MATLAB Function Blocks
• Using Global Data with the MATLAB Function Block
When Do You Need to Use Global Data?
Using Global Data with the MATLAB Function Block
Choosing How to Store Global Data
How to Use Data Store Memory Blocks
How to Use Simulink.Signal Objects
• Working with Frame-Based Signals
• Creating Custom Block Libraries with MATLAB Function Blocks
When to Use MATLAB Function Block Libraries
How to Create Custom MATLAB Function Block Libraries
Example: Creating a Custom Signal Processing Filter Block Library
Code Reuse with Library Blocks
Debugging MATLAB Function Library Blocks
Properties You Can Specialize Across Instances of Library Blocks
• Using Traceability in MATLAB Function Blocks
• Including MATLAB Source Code as Comments in the Generated Code
How to Include MATLAB Code as Comments in the Generated Code
Location of Comments in Generated Code
• Enhancing Readability of Generated Code for MATLAB Function Blocks
Requirements for Using Readability Optimizations
Converting If-Elseif-Else Code to Switch-Case Statements
Example of Converting Code for If-Elseif-Else Decision Logic to Switch-Case Statements
• Speeding Up Simulation with the Basic Linear Algebra Subprograms (BLAS) Library
How MATLAB Function Blocks Use the BLAS Library
When to Disable BLAS Library Support
• Tutorial: Integrating MATLAB Code with a Simulink Model for Tracking a Moving Object
• Tutorial: Integrating MATLAB Code with a Simulink Model for Filtering an Audio Signal
Data Types Supported by Simulink
Block Support for Data and Numeric Signal Types
Creating Signals of a Specific Data Type
Specifying Block Output Data Types
Validating a Floating-Point Embedded Model
Tutorial: Validating a Single-Precision Model
Using the Model Explorer to Create Data Objects
Saving and Loading Data Objects
Using Data Objects in Simulink Models
Creating Persistent Data Objects
Disadvantages of Level-1 Data Class Infrastructure
Features of Level-2 Data Class Infrastructure
Other Differences between Level-1 and Level-2 Data Classes
Enabling Custom Storage Classes
Valid Values for Design Minimum and Maximum
Creating a Simulink Enumeration Class
Customizing a Simulink Enumeration
Saving an Enumeration in a MATLAB File
Changing and Reloading Enumerations
Importing Enumerations Defined Externally to MATLAB
Specifying Enumerations as Data Types
Getting Information About Enumerations
Enumerated Values in Computation
Enumerated Types for Switch Blocks
Approaches for Exporting Signal Data
Enabling Simulation Data Export
Viewing Logged Simulation Data With the Simulation Data Inspector
Data Format for Model-Based Exported Data
Producing Specified Output Only
Limiting the Data Logged for a Signal
Using the Model Editor to View the Signal Logging Configuration
Using the Signal Logging Selector to View the Signal Logging Configuration
Using the Model Explorer to View the Signal Logging Configuration
Specifying the Signal Logging Data Format
Specifying a Name for the Signal Logging Data
Two Interfaces for Overriding Signal Logging Settings
Scope of Signal Logging Setting Overrides
Command-Line Interface for Overriding Signal Logging Settings
Viewing Logged Signal Data with the Simulation Data Inspector
Programmatically Accessing Logged Signal Data Saved in Dataset Format
Programmatically Accessing Logged Signal Data Saved in ModelDataLogs Format
Guidelines for Specifying Time and Signal Values for Imported Data
Example of Importing Data to Model a Continuous Plant
Example of Importing Data to Test a Discrete Algorithm
Using a From Workspace Block to Import an Input Test Case
Using a Signal Builder Block to Import an Input Test Case
Models with Multiple Root Inport Blocks
When to Use a Structure of MATLAB timeseries Objects Instead of a Simulink.TsArray Object
How to Use a Structure of MATLAB timeseries Objects to Import Bus Signals
Specifying the Input Expression
One Structure for All Ports or a Structure for Each Port
Examples of Specifying Signal and Time Data
Importing and Exporting State Information for Referenced Models
Workflow for Configuring Data Stores
Using Data Stores with Buses and Arrays of Buses
Specifying Data Store Memory Block Attributes
Specifying Signal Object Data Store Attributes
Accessing Specific Bus and Matrix Elements
Supported Data Types, Dimensions, and Complexity for Logging Data Stores
Data Store Logging Limitations
Logging Data Stores Created with a Data Store Memory Block
Logging Icon for the Data Store Memory Block
Logging Data Stores Created with a Simulink.Signal Object
Accessing Data Store Logging Data
Ordering Access Using Function Call Subsystems
Ordering Access Using Block Priorities
Detecting Multitasking Access Errors
Signal Dimensions, Size, and Width
Displaying Signal Values in Model Diagrams
Propagated Signal Label Format
Blocks That Support Signal Label Propagation
Display Propagated Signal Labels
How Simulink Propagates Signal Labels
Simulink Blocks that Support Multidimensional Signals
Determining the Output Dimensions of Source Blocks
Determining the Output Dimensions of Nonsource Blocks
Signal and Parameter Dimension Rules
Scalar Expansion of Inputs and Parameters
Highlighting Signal Destinations
Resolving Incomplete Highlighting to Library Blocks
Blocks That Allow Signal Range Specification
Checking for Signal Range Errors
Using Block Parameters to Initialize Signals and Discrete States
Using Signal Objects to Initialize Signals and Discrete States
Using Signal Objects to Tune Initial Values
Example: Using a Signal Object to Initialize a Subsystem Output
Initialization Behavior Summary for Signal Objects
Designating a Signal as a Test Point
Displaying Test Point Indicators
Printing, Exporting, and Copying Waveforms
Associating Bus Objects with Simulink Blocks
Writing a Bus Object Import Function
Writing a Bus Object Export Function
Connecting Buses to Root Level Outports
Connecting Buses to Nonvirtual Inports
Connecting Buses to Model, Stateflow, and MATLAB Function Blocks
Connecting Multi-Rate Buses to Referenced Models
Creating Initial Condition (IC) Structures
Three Ways to Initialize Bus Signals Using Block Parameters
Setting Diagnostics to Support Bus Signal Initialization
Blocks That Support Arrays of Buses
Using an Array of Buses in a Model
Generated Code for an Array of Buses
Converting a Model to Use an Array of Buses
Using Diagnostics for Mux/Bus Mixtures
Using the Model Advisor for Mux/Bus Mixtures
Correcting Buses Used as Muxes
Bus to Vector Block Compatibility Issues
Avoiding Mux/Bus Mixtures When Developing Models
Creating Variable-Size Signals
How Variable-Size Signals Propagate
Subsystem Initialization of Variable-Size Signals
Demo of Variable-Size Signal Length Adaptation
Demo of Mode-Dependent Variable-Size Signals
Demo of C S-Function with Variable-Size Signals
• Customizing Simulink Environment and Printed Models
About Adding Items to the Model Editor Menus
Registering Menu Customizations
Debugging Custom Menu Callbacks
About Disabling and Hiding Model Editor Menu Items
Example: Disabling the New Model Command on the Simulink Editor's File Menu
About Disabling and Hiding Controls
Example: Disabling a Button on a Simulink Dialog Box
Writing Control Customization Callback Functions
Registering Control Customization Callback Functions
Disabling and Hiding Libraries
Customizing the Library Browser's Menu
Starting the PrintFrame Editor
Getting Help for the PrintFrame Editor
Variable and Static Information
Single Use or Multiple Use Print Frames
• Running Models on Target Hardware
Passing Parameters to S-Functions
Mathematics of Simulink Blocks
Setting Sample Times and Offsets
Level-2 MATLAB S-Function Examples
Level-1 MATLAB S-Function Examples
Using a Hand-Written S-Function to Incorporate Legacy Code
Using the S-Function Builder to Incorporate Legacy Code
Using the Legacy Code Tool to Incorporate Legacy Code
Level-2 MATLAB S-Function Template
Level-2 MATLAB S-Function Callback Methods
Example of Writing a Level-2 MATLAB S-Function
Instantiating a Level-2 MATLAB S-Function
Operations for Variable-Size Signals
Generating Code from a Level-2 MATLAB S-Function
Level-1 MATLAB S-Function Arguments
Level-1 MATLAB S-Function Outputs
Defining S-Function Block Characteristics
Processing S-Function Parameters
Converting Level-1 MATLAB S-Functions to Level-2
Deploying the Generated S-Function
How the S-Function Builder Builds an S-Function
Parameters/S-Function Name Pane
Example: Modeling a Two-Input/Two-Output System
Callback Method Implementations
Simulink/Simulink Coder Interfaces
S-Function Source File Requirements
Example of Integrating Existing C Functions into Simulink Models with the Legacy Code Tool
Registering Legacy Code Tool Data Structures
Declaring Legacy Code Tool Function Specifications
Generating and Compiling the S-Functions
Generating a Masked S-Function Block for Calling a Generated S-Function
Forcing Simulink Accelerator Mode to Use S-Function TLC Inlining Code
Handling Multiple Registration Files
Deploying Generated S-Functions
Debugging C MEX S-Functions in the Simulink Environment
Debugging C MEX S-Functions Using Third-Party Software
Example of a Level-1 Fortran S-Function
Inline Code Generation Example
Example C MEX S-Function Calling Fortran Code
DWork Vectors and the Simulink Engine
DWork Vectors and the Simulink Coder Product
Using DWork Vectors in Level-2 MATLAB S-Functions
Using DWork Vectors With Legacy Code
Level-2 MATLAB S-Function DWork Vector
Elementary Work Vector Examples
Creating Input Ports for Level-2 MATLAB S-Functions
Creating Output Ports for C S-Functions
Creating Output Ports for Level-2 MATLAB S-Functions
Using Custom Data Types in Level-2 MATLAB S-Functions
Specifying Port-Based Sample Times
Hybrid Block-Based and Port-Based Sample Times
Multirate S-Functions and Sample Time Hit Calculations
Synchronizing Multirate S-Function Blocks
Specifying Model Reference Sample Time Inheritance
SimState Compliance Specification for C-MEX S-Functions
Using Frame-Based Signals in C S-Functions
Using Frame-Based Signals in Level-2 MATLAB S-Functions
ssSetErrorStatus Termination Criteria
• Blocks
MATLAB Function blocks participate in signal resolution with Simulink signal objects. By default, output data from MATLAB Function blocks become associated with Simulink signal objects of the same name during a process called implicit signal resolution, as described in Simulink.Signal in the Reference documentation.
By default, implicit signal resolution generates a warning when you update the chart in the Simulink model. The following sections show you how to manage implicit signal resolution at various levels of the model hierarchy. See Resolving Symbols and Explicit and Implicit Symbol Resolution for more information.
To enable implicit signal resolution for all signals in a model, but eliminate the attendant warnings, follow these steps:
In the Simulink Model Editor, select Simulation > Configuration Parameters.
The Configuration Parameters dialog appears.
In the left pane of the Configuration Parameters dialog, under Diagnostics, select Data Validity.
Data Validity configuration parameters appear in the right pane.
In the Signal resolution field, select Explicit and implicit.
To disable implicit signal resolution for a MATLAB Function block in your model, follow these steps:
Right-click the MATLAB Function block and select Subsystem Parameters in the context menu.
The Block Parameters dialog opens.
In the Permit hierarchical resolution field, select ExplicitOnly or None, and click OK.
To force signal resolution for an output signal in a MATLAB Function block, follow these steps:
In the Simulink model, right-click the signal line connected to the output that you want to resolve and select Signal Properties from the context menu.
In the Signal Properties dialog, enter a name for the signal that corresponds to the signal object.
Select the Signal name must resolve to Simulink signal object check box and click OK.
![]() | Parameter Arguments in MATLAB Function Block Functions | Working with Structures and Bus Signals | ![]() |

Learn more about Simulink through this collection of videos, articles, technical literature and the Getting Started with Simulink Guide.
| © 1984-2012- The MathWorks, Inc. - Site Help - Patents - Trademarks - Privacy Policy - Preventing Piracy - RSS |


