Guy on Simulink

Simulink & Model-Based Design

The Most Impactful Recent Features in Simulink

I have been recently asked this question:
What are the top 10 most impactful and recent features for Simulink and Model-Based Design?
It's a tricky question because different workflows are impacted by different features. Something life-changing for one user can go unnoticed by someone else. Also, the meaning of "recent" depends a lot on how often you update to new versions.
I have been supporting Simulink users and writing this blog for more than 15 years. When coming up with the following list, I tried to reflect on how the workflows I see the most when talking to users have changed throughout the years and which features have impacted them the most.
I decided to divide this in four categories:
  • Model Execution and Performance
  • Model Management
  • Model Authoring
  • Toolboxes and Blocksets

Model Execution and Performance

Let's state the obvious: We all like it when simulations run fast!
To help with that, we published in the last few years a technical article (Improving Simulation Performance in Simulink) and a YouTube livestream (Speed up Simulink Simulation Workflows). Here are three features highlighted in this article and video.

Model Reference - Accelerated and Protected

The Model Reference technology has been in Simulink for many years. It enables using a Simulink model as part of another model. The reason why I am mentioning it here is that it can help a lot with performance, especially the time it takes to initialize a simulation.
In MathWorks Technical Support, we often receive questions along the line of "How can I make my Simulink model faster?".
At each release cycle, we review and analyze the requests we received and how we addressed them. In the last few years, the feature that helped users speed up their simulation the most is accelerated and protected referenced models. When used properly (see this post on chache and rebuild), model referencing can significantly speed up the time required to initialize a simulation.
Here is a slide from our YouTube livestream that I like to use to describe my recommended workflow with referenced models:
The assumption here is that when dealing with large simulations, on a given day, most users only need to modify a small part of it. If that's your case, do two things:
  • Place the parts you are not modifying in referenced models configured to run in accelerator mode. It will take some time to pre-compile them the first time, but for subsequent simulation they will initialize instantly.
  • For the parts you are actively working on, place them either in the top model, inside a referenced subsystem, or inside a referenced model configured to run in normal mode.

Fast Restart

Fast Restart complements model reference very well. It is useful for cases where you need to run many simulations without making structural changes to a model. We call it the "Tune-Sim-Repeat" workflow:
With Fast Restart enabled, the model will be compiled once. At the end of the simulation, the status bar will look like this:
When in that mode, the initialization time of the next simulation will go down to practically zero.
Many Simulink features have options to leverage Fast Restart. The first ones that come to my mind are:

Parsim and Batchsim

Parsim and batchsim make it easy to run multiple simulations in parallel. Before the introduction of those functions, simulating models in parallel was quite complex. At that time, I wrote this blog post to explain all the subtleties to get the data needed by the simulation available to the parallel workers.
In newer versions of MATLAB, you can almost always simply replace the sim command with parsim or batchsim and it just works.
Parsim and batchsim do not make one simulation faster, what they enable is running multiple simulations at the same time, either on your local computer, on a MATLAB Parallel Server, or in the cloud.
When using parsim, you can use the Simulation Manager to monitor the progress of your simulations

Model Management and Componentization

When not done properly, model management and componentization can cause a lot of headaches. Here are 3 features that can help with that.

Projects

Initially introduced as "Simulink Projects", we now talk about MATLAB Projects because they apply not only to Simulink, but to the entire MathWorks ecosystem.
Project are super useful to organize all the files around a Simulink model and automate common tasks. Even when I receive files from users that are not inside a project, I often create a project to make my life easier.
When I start writing a new blog post like this one, I always start from a Project Template that I created at the time when I decided to make it possible to view and run posts in MATLAB Online. (You can download my Project Template).
My favorite features with Projects are:
Projects can also reference other projects to componentize large projects.

Variants

With variants, a single Simulink model can contain multiple designs, and you can decide which one is active when the model is simulated or when you generate code from it. You can control the active variant using expressions and/or variant configurations.
The classic example is a simulation that can be configured to represent a vehicle with a gasoline engine, an electric motor, or a hybrid drivetrain.
If you want to learn more about all the possibilities enabled by variants, I recommend:
If you are already using variants, I recommend looking at the Variant Manager. This tool can help manage, reduce and analyze variants present in your Simulink models.

Subsystem Reference

Subsystem Reference enables something simple and obvious but very useful: Save the content of a Subsystem in a separate file.
In my opinion, this provides a perfect complementary solution to referenced models, which have a stricter interface (which enables more possibilities as described above), and libraries, which are better suited for a collection of blocks changing infrequently to be shared with many users.
If you are not sure when to use model reference, versus subsystem reference, versus libraries, see: Component-Based Modeling Guidelines

Model Authoring

In my work, I edit Simulink models all day, every day. Because of that, features that allow me to edit models faster and more efficiently have a huge impact.
Tons of enhancements have been added to the Simulink editor throughout the years. Out of the lot, two stand out to me.

Quick Insert

Before Quick Insert, we had to navigate the Library Browser, find the blocks you wanted and drag them into the canvas. Since the introduction of Quick Insert, you can simply type what you need in the canvas and hit Enter. On top of that, if you double-click on the tip of an unconnected line, the Quick Insert menu will offer the blocks you are the most likely to want to add based on the context. You can even train this algorithm with your own models:
QuickInsert.gif
Once you are in the Quick Insert menu, you can toggle to Action Search using the keyboard shortcut "Ctrl+." and search for Simulink actions and apps:

Commenting Blocks

I must admit, the first time I heard plans to add the possibility to comment blocks, my reaction was: Why would someone need that? If I want to temporarily remove blocks from a model, I can cut and paste them in an empty temporary model.
I was so young and innocent...
Today, I comment out and comment through blocks all day every day and I rarely receive models from users that don't have at least a few blocks commented out.

Pro Tip:

The keyboard shortcuts for commenting blocks are:
  • Comment out: Ctrl+Shift+X
  • Comment through: Ctrl+Shift+Y
Other apps on your computer might also use Ctrl+Shift+X and could highjack it from Simulink (SnagIt, the software I use to take screenshot for this blog, does that). I personally disable those in other software so Ctrl+Shitf+X can remain associated with Simulink.
Comment.gif

Toolboxes and Blocksets

Let's talk about toolboxes and blocksets that build on top of the Simulink foundation.

The Simscape Family

What started initially with simple mechanical and hydraulic domains can now be used to model pretty much anything you can think of. Here is a screenshot from the documentation listing all the domains available:
And if there is not a domain for what you need, you can create your own using the Simscape Language.
If you have not used Simscape yet, here is a screenshot of a model simulating a Medical Ventilator with Lung Model. It combines mechanical, thermal, and moist air domains.
I personally receive tons of models from users that are composed of a plant and a controller. Throughout the years, the percentage of models using Simscape for plant modeling has continuously increased. In the last few years, I think I have seen more models where the plant is modeled using Simscape than Simulink continuous blocks.

Simulink Compiler

Simulink Compiler enables you to share Simulink simulations with anyone who does not have MATLAB.
I like to oversimplify the concept of Simulink Compiler by saying that all it does is add support to the sim command to MATLAB Compiler. It's a bit more than that, but with Simulink Compiler you can turn any Simulink simulation into:

Now it's your turn

Tell us in the comments below which recent Simulink features impacted your workflows the most.

|
  • print

댓글

댓글을 남기려면 링크 를 클릭하여 MathWorks 계정에 로그인하거나 계정을 새로 만드십시오.