{"id":81,"date":"2010-02-04T01:39:28","date_gmt":"2010-02-04T01:39:28","guid":{"rendered":"https:\/\/blogs.mathworks.com\/seth\/2010\/02\/04\/new-since-r2009a-simulink-inside-sateflow\/"},"modified":"2016-12-30T14:52:52","modified_gmt":"2016-12-30T19:52:52","slug":"new-since-r2009a-simulink-inside-sateflow","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/simulink\/2010\/02\/04\/new-since-r2009a-simulink-inside-sateflow\/","title":{"rendered":"New (Since R2009a) Simulink inside Stateflow"},"content":{"rendered":"<p>This week I asked Michael Carone to introduce a relatively\r\nnew Stateflow capability, Simulink Functions.<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2010Q1\/michael_carone_bevel.jpg\" alt=\"Stateflow expert Michael Carone\"><\/p>\r\n\r\n<p>Did you ever want to put a Simulink block inside of a\r\nStateflow chart?\u00a0 Well, if you have R2009a\r\nor <a href=\"https:\/\/www.mathworks.com\/products\/new_products\/latest_features.html\">R2009b<\/a>,\r\nyou can!<\/p>\r\n\r\n<p><img decoding=\"async\" src=\"https:\/\/blogs.mathworks.com\/images\/seth\/2010Q1\/SimulinkInStateflow.png\" alt=\"Simulink subsystems inside Stateflow Charts.\"><\/p>\r\n\r\n<p>When you open your Stateflow chart, you\u2019ll see a new white\r\nbutton that looks like a Simulink subsystem on the bottom of the graphical\r\npalette.\u00a0 Use that button to drag in a Simulink function (just like you would\r\nfor an Embedded MATLAB function), double-click on the function, and you have a\r\nSimulink window for creating your new Simulink function.\u00a0 Or if you have a\r\nfunction already built in Simulink that you want to embed in Stateflow, just\r\ncopy and paste that block from Simulink into Stateflow (new for R2009b).<\/p>\r\n\r\n<p>Now some of you might be asking, \u201cWhy would I want to do\r\nthis?\u201d\u00a0 Well, there are a few applications that immediately come to my mind.\u00a0\r\nMaybe you have an algorithm you already designed in Simulink that you want to\r\nreuse in Stateflow.\u00a0 Or maybe you want to use Stateflow to schedule exactly\r\nwhen to trigger a specific task or controller.\u00a0 You might also want to control\r\nthe behavior of separate components modeled in Simulink.\u00a0 <\/p>\r\n\r\n<p>Check out this MATLAB\r\nDigest article if you want to see some design patterns for using Simulink\r\nfunctions in Stateflow.\u00a0 Or go to the <a\r\nhref=\"https:\/\/www.mathworks.com\/help\/releases\/R2009b\/toolbox\/stateflow\/ug\/brmtjej-1.html\">documentation<\/a>\r\nif you really want to get all the details.<\/p>\r\n\r\n<p><strong>Now it\u2019s Your Turn<\/strong><\/p>\r\n\r\n<p>Can you see how embedding Simulink functions in Stateflow\r\ncharts would be helpful for your models?\u00a0 Leave a <a\r\nhref=\"https:\/\/blogs.mathworks.com\/seth\/?p=81&amp;#comment\">comment below<\/a> and\r\nlet me know.<\/p>","protected":false},"excerpt":{"rendered":"<p>This week I asked Michael Carone to introduce a relatively\r\nnew Stateflow capability, Simulink Functions.\r\n\r\n\r\n\r\nDid you ever want to put a Simulink block inside of a\r\nStateflow chart?\u00a0 Well, if you... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/simulink\/2010\/02\/04\/new-since-r2009a-simulink-inside-sateflow\/\">read more >><\/a><\/p>","protected":false},"author":40,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[56,16],"tags":[120,455],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/81"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/users\/40"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/comments?post=81"}],"version-history":[{"count":2,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/81\/revisions"}],"predecessor-version":[{"id":6147,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/posts\/81\/revisions\/6147"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/media?parent=81"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/categories?post=81"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/simulink\/wp-json\/wp\/v2\/tags?post=81"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}