Functions in Stateflow(Stateflow中的函数)
Stateflow supports the creation of various types of functions that can be called multiple times within a chart. As with textual programming, using functions reduces redundancy and improves readability. In this course, you will learn about two types of Stateflow functions: graphical functions and MATLAB functions. You can learn about other types of functions by browsing the documentation page, Reusable Functions in Charts. Functions can be called as state actions and condition actions. If a function returns a Boolean value, it can also be called as a transition condition.
(Stateflow支持创建各种类型的函数,这些函数可以在图表中多次调用。与文本编程一样,使用函数可以减少冗余并提高可读性。在本课程中,您将了解两种类型的Stateflow函数:图形函数和MATLAB函数。您可以通过浏览文档页面“图表中的可重用函数”来了解其他类型的函数。函数可以称为状态操作和条件操作。如果函数返回布尔值,也可以将其称为转换条件。)
Graphical Functions(图形功能)
Graphical functions are reusable chart elements that contain flow charts. As you saw previously, a flow chart can be inserted directly into a Stateflow chart. However, you can reuse this logic by encapsulating it into a graphical function. To add a graphical function, use the left mouse button to click and drag from the icon on the object palette (fx). This will create a function container for you to name and populate.
(图形函数是包含流程图的可重用图表元素。正如您之前看到的,流程图可以直接插入到状态流程图中。但是,您可以通过将此逻辑封装到图形函数中来重用它。要添加图形功能,请使用鼠标左键单击对象调色板上的图标并进行拖动(fx)。这将创建一个函数容器,供您命名和填充。)
MATLAB Functions(MATLAB函数)
It can also be helpful to incorporate textual MATLAB functions into a Stateflow chart. For example, it may be easier t