Guy on Simulink

Simulink & Model-Based Design

New (Since R2009a) Simulink inside Stateflow

This week I asked Michael Carone to introduce a relatively new Stateflow capability, Simulink Functions.

Stateflow expert Michael Carone

Did you ever want to put a Simulink block inside of a Stateflow chart?  Well, if you have R2009a or R2009b, you can!

Simulink subsystems inside Stateflow Charts.

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.

|
  • print

评论

要发表评论,请点击 此处 登录到您的 MathWorks 帐户或创建一个新帐户。