Simulink

Key Features

  • Graphical editor for building and managing hierarchical block diagrams
  • Libraries of predefined blocks for modeling continuous-time and discrete-time systems
  • Simulation engine with fixed-step and variable-step ODE solvers
  • Scopes and data displays for viewing simulation results
  • Project and data management tools for managing model files and data
  • Model analysis tools for refining model architecture and increasing simulation speed
  • MATLAB Function block for importing MATLAB algorithms into models
  • Legacy Code Tool for importing C and C++  code into models

Building the Model

Simulink® provides a set of predefined blocks that you can combine to create a detailed block diagram of your system. Tools for hierarchical modeling, data management, and subsystem customization enable you to represent even the most complex system concisely and accurately.

Selecting Blocks

The Simulink Library Browser includes:

  • Continuous and discrete dynamics blocks, such as Integration and Unit Delay
  • Algorithmic blocks, such as Sum, Product, and Lookup Table
  • Structural blocks, such as Mux, Switch, and Bus Selector

You can build customized functions by using these blocks or by incorporating hand-written MATLAB®, C, Fortran, or Ada code into your model.

Your custom blocks can be stored in their own libraries within the Simulink Library Browser.

Simulink add-on products let you incorporate specialized components for aerospace, communications, PID control, control logic, signal processing, video and image processing, and other applications. Add-on products are also available for modeling physical systems with mechanical, electrical, and hydraulic components.

Incorporating MATLAB Algorithms into a Simulink Model 2:04
Use MATLAB Function block to incorporate MATLAB® code in a Simulink® model.

Building and Editing the Model

You build a model by dragging blocks from the Simulink Library Browser into the Simulink Editor.  You then connect these blocks with signal lines to establish mathematical relationships between system components.  Graphical formatting tools, such as smart guides and smart signal routing, help you control the appearance of your model as you build it.  You can add hierarchy by encapsulating a group of blocks and signals as a subsystem in a single block.

The Simulink Editor gives you complete control over what you see and use within the model.  For example, you can add commands and submenus to the editor and context menus.  You can also add a custom interface to a subsystem or model by using a mask that hides the subsystem's contents and provides the subsystem with its own icon and parameter dialog box.

Getting Started with Simulink 3:20
Build and simulate a model with Simulink®.

Navigating Through the Model Hierarchy

The Explorer bar and Model Browser in Simulink help you navigate your model. The Explorer bar indicates the level of hierarchy that you are currently viewing and lets you move up and down the hierarchy. The Model Browser provides a complete hierarchical tree view of your model, and like the Explorer bar, can be used to move through the levels of hierarchy.

Navigating a Hierarchical Model 1:46
The Explorer bar, tabbed windows, and Model Browser help you navigate a hierarchical model.

Managing Signals and Parameters

Simulink models contain both signals and parameters.  Signals are time-varying data represented by the lines connecting blocks.  Parameters are coefficients that define system dynamics and behavior.

Simulink helps you determine the following signal and parameter attributes:

  • Data type—single, double, signed, or unsigned 8-, 16- or 32-bit integers; Boolean; enumeration; or fixed point
  • Dimensions—scalar, vector, matrix, N-D, or variable-sized arrays
  • Complexity—real or complex values
  • Minimum and maximum range, initial value, and engineering units

If you choose not to specify data attributes, Simulink determines them automatically via propagation algorithms, and conducts consistency checking to ensure data integrity.

These signal and parameter attributes can be specified either within the model or in a separate data dictionary. You can then use the Model Explorer to organize, view, modify, and add data without navigating through the entire model.

Block dialog box showing the Signal Attributes tab.
Enlarge Block dialog box showing the Signal Attributes tab.

Simulating the Model

You can simulate the dynamic behavior of your system and view the results as the simulation runs. To ensure simulation speed and accuracy, Simulink provides fixed-step and variable-step ODE solvers, a graphical debugger, and a model profiler.

Choosing a Solver

Solvers are numerical integration algorithms that compute the system dynamics over time using information contained in the model. Simulink provides solvers to support the simulation of a broad range of systems, including continuous-time (analog), discrete-time (digital), hybrid (mixed-signal), and multirate systems of any size.

These solvers can simulate stiff systems and systems with discontinuities. You can specify simulation options, including the type and properties of the solver, simulation start and stop times, and whether to load or save simulation data.  You can also set optimization and diagnostic information.  Different combinations of options can be saved with the model.

Configuration Parameters dialog box showing the Solver pane.
Enlarge Configuration Parameters dialog box showing the Solver pane.

Running the Simulation

You can run your simulation interactively from the Simulink Editor or systematically from the MATLAB command line.  The following simulation modes are available:

  • Normal (the default), which interpretively simulates your model
  • Accelerator, which increases simulation performance by creating and executing compiled target code but still provides the flexibility to change model parameters during simulation
  • Rapid Accelerator, which can simulate models faster than Accelerator mode by creating an executable that can run outside Simulink on a second processing core

To reduce the time required to run multiple simulations, you can run those simulations in parallel on a multi-core computer or computer cluster.

Running Multiple Simulink Simulations in Parallel 2:29
Run your multiple simulations faster through the use of parallel computing.

Analyzing Simulation Results

After running a simulation, you can analyze the simulation results in MATLAB and Simulink. Simulink includes debugging tools to help you understand the simulation behavior.

Viewing Simulation Results

You can visualize the simulation behavior by viewing signals with the displays and scopes provided in Simulink. You can also view simulation data within the Simulation Data Inspector, where you can compare multiple signals from different simulation runs.

Alternatively, you can build custom HMI displays using MATLAB, or log signals to the MATLAB workspace to view and analyze the data using MATLAB algorithms and visualization tools.

Visualizing Simulation Results 2:51
Visualize simulation results using scopes and viewers.

Debugging the Simulation

Simulink supports debugging with the Simulation Stepper, which lets you step back and forth through your simulation viewing data on scopes or inspecting how and when the system changes states.

With the Simulink debugger you can step through a simulation one method at a time and examine the results of executing that method. As the model simulates, you can display information on block states, block inputs and outputs, and block method execution within the Simulink Editor.

Rewinding a Simulation 1:29
Step back and forward through your simulation to analyze system behavior.

Managing Projects

Simulink provides tools to help you manage project-related files, components, and large amounts of data.

Managing Project-Related Files

Simulink Projects is an interactive tool for managing project files and connecting to source control software. The Simulink Projects tool promotes collaboration across teams by enabling you to:

  • Find all project-related files
  • Create shortcuts for accessing common operations and initializing and shutting down projects
  • Label modified files for peer review
  • Share projects using Apache™ Subversion® (SVN), an external source control tool

Simulink Projects provides connectivity to tools for source control, version control, software configuration management (SCM), product lifecycle management (PLM), and application lifecycle management (ALM). You can create a custom adapter for other third-party source control tools using the Simulink Projects Source Control SDK.

Team Collaboration with Simulink Projects 1:14
Get an overview of team collaboration with Simulink® Projects.

Building Design Components

Simulink facilitates component-based modeling and modular design. You can segment your model into design components and then model, simulate, and verify each component independently. You can save components as subsystems in a library, or use model referencing to save components as separate models. Team members can then work on those components in parallel.

You can manage design variants in the same model using Model Variants and Variant Subsystems. This capability simplifies the creation and management of designs that share components, as one model can represent a family of designs.

Modular Design Using Model Referencing 2:49
Explore the value of model referencing for component-based modeling.

Managing Large-Scale Data

Bus signals are provided in Simulink for managing a large set of signal data in your model. With bus signals you can consolidate multiple signals into one object, making it easier to connect those signals to another block. You can also define an array of buses to manage a group of bus objects within one package.

The Model Explorer is a graphical data dictionary tool that helps you organize, view, modify, and add data to your Simulink models.  With the Model Explorer you can:

  • Customize the interface to show only the data and properties that you want to see 
  • Control the scope of the data to define which components have access to that data

Creating and Masking Subsystems 3:09
Create hierarchy and modularize system behavior using subsystems.

Connecting to Hardware

You can connect your Simulink model to hardware for rapid prototyping, hardware-in the-loop (HIL) simulation, and deployment on an embedded system.

Running Simulations on Hardware

Simulink provides built-in support for prototyping, testing, and running models on low-cost target hardware, such as Arduino®, LEGO® MINDSTORMS® NXT, and Raspberry Pi. You can design algorithms in Simulink for control systems, robotics, audio processing, and computer vision applications and see them perform in real time.

With Real-Time Windows Target™, you can run Simulink models in real time on Microsoft® Windows® PCs and connect to a range of I/O boards to create and control a real-time system. To run your model in real time on a target computer, you can use Simulink Real-Time™ for HIL simulation, rapid control prototyping, and other real-time testing applications. See xPC Target Turnkey for available target computer hardware.

Introduction to Simulink Support for Target Hardware 1:55
Simulink provides built-in support for prototyping, testing, and running models on low-cost target hardware, such as Arduino®, LEGO® MINDSTORMS® NXT, and Raspberry Pi.

Generating Code

Simulink models can be configured and made ready for code generation. By using Simulink with add-on code generation products, you can generate C and C++, HDL, or PLC code directly from your model.

Ask The Simulink Expert

Simulink News

MATLAB and Simulink Deployed to International Space Station for NASA SPHERES Project (press release)

UMathWorks today announced that MATLAB and Simulink have been deployed to the International Space Station as part of NASA’s Synchronized Position Hold Engage and Reorient Experimental Satellites (SPHERES) project.

Read more

Latest from the Simulink Community