MATLAB: How to change the default Stateflow chart properties

chart;defaultpropertiesset_paramstateflow

For example, I want to set the default chart property "Use Strong Data Typing with Simulink I/O" to be checked, so when I create a new Stateflow chart, this property is checked.

Best Answer

There are two ways to change the default Stateflow chart properties:
-----------------------
1. Using the Stateflow API
Run the following code after starting MATLAB:
load_system('sflib');
set_param('sflib','Lock','off')
rt = sfroot;
m = rt.find('-isa','Stateflow.Machine','Name','sflib');
chart = m.findDeep('Chart');
chart.StrongDataTypingWithSimulink = 1;
Remark: For newer releases change the last line to:
chart(1).StrongDataTypingWithSimulink = 1;
When you open a new Stateflow chart, the chart property "Use Strong Data Typing with Simulink I/O" will be checked. You can change other default properties using the similar methods. More information on Stateflow API can be found at:
You can also save the above code to the file startup.m. It will take effect automatically every time when you start MATLAB. More information on setting the file startup.m can be found at:
Please be aware that you manually change the Stateflow library without saving.
-----------------------
2. Using the Simulink Library Browser
Type the following in the MATLAB command window:
simulink
Click on "Stateflow" on the Simulink Library Browser tree, then double click the "Chart" block. Right click on the opened chart, select "Properties". Check the option "Use Strong Data Typing with Simulink I/O" and close the chart. (Note: Do not save the chart unless you want to change the chart property permanently, which is not recommended.) After doing this, if you open a new Stateflow chart, the chart property "Use Strong Data Typing with Simulink I/O" will be checked.