When do I use Stateflow subcharts/atomic subcharts?

2 次查看(过去 30 天)
I get warnings na_0038 and na_0040 from Model Advisor about my Stateflow chart. What is the advantage of a Stateflow subchart? Is it Functional or Non-Functional? Does it have anything to do with cyclomatic complexity?

采纳的回答

MathWorks Support Team
编辑:MathWorks Support Team 2024-3-1
Subcharts/atomic subcharts can be thought of as Stateflow's version of subsystems/atomic subsystems. In this way, they mirror in terms of function and non-functional effect. Subcharts (like virtual subsystems) affect only the readability/organization of the chart. Atomic subcharts on the other hand, create re-usable components which affect both model compilation time and code generation. See here for an overview of atomic subcharts:
Atomic subcharts add to the cyclomatic complexity because they count as new components. See here for reference:
Please run the below in the command window of installed MATLAB R2018b version to get release specific documentation
web(fullfile(docroot, 'slcoverage/ug/model-coverage-for-stateflow-charts.html'))
However, in many cases the benefits of having such charts outweigh the uptick in complexity. At any time, you can check your complexity using the Model Advisor ("By Task" > "Model Metrics"> "Complexity Metrics").
As for your specific warnings, na_0038  is recommended for readability and na_0040 is recommended for both readability and code generation organization. In terms of the code generation, atomic subcharts can create code for the standalone component, potentially making the generated code easier to trace and debug. See below for reference:
Please run the below in the command window of installed MATLAB R2018b version to get release specific documentation
web(fullfile(docroot, 'simulink/mdl_gd/maab/na_0038levelsinstateflowcharts.html'))
Please run the below in the command window of installed MATLAB R2018b version to get release specific documentation
web(fullfile(docroot, 'simulink/mdl_gd/maab/na_0040numberofstatespercontainer.html'))
Note that both na_0038 and na_0040 were removed starting in R2020a with an update to the MAB Guideline. See the release notes for details: https://www.mathworks.com/help/simulink/release-notes.html#mw_6355f8fe-259e-4c67-a8bd-5ecf4a8e8cf7
Please follow the below link to search for the required information regarding the current release:
https://www.mathworks.com/help/

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Modeling 的更多信息

产品


版本

R2021a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by