New (Since R2009a) Simulink inside Stateflow
This week I asked Michael Carone to introduce a relatively new Stateflow capability, Simulink Functions.
Did you ever want to put a Simulink block inside of a Stateflow chart? Well, if you have R2009a or R2009b, you can!
When you open your Stateflow chart, you’ll see a new white button that looks like a Simulink subsystem on the bottom of the graphical palette. Use that button to drag in a Simulink function (just like you would for an Embedded MATLAB function), double-click on the function, and you have a Simulink window for creating your new Simulink function. Or if you have a function already built in Simulink that you want to embed in Stateflow, just copy and paste that block from Simulink into Stateflow (new for R2009b).
Now some of you might be asking, “Why would I want to do this?” Well, there are a few applications that immediately come to my mind. Maybe you have an algorithm you already designed in Simulink that you want to reuse in Stateflow. Or maybe you want to use Stateflow to schedule exactly when to trigger a specific task or controller. You might also want to control the behavior of separate components modeled in Simulink.
Check out this MATLAB Digest article if you want to see some design patterns for using Simulink functions in Stateflow. Or go to the documentation if you really want to get all the details.
Now it’s Your Turn
Can you see how embedding Simulink functions in Stateflow charts would be helpful for your models? Leave a comment below and let me know.
- Category:
- Stateflow,
- What's new?
Comments
To leave a comment, please click here to sign in to your MathWorks Account or create a new one.