Programatically create a new Stateflow chart inside an existing subsystem
Show older comments
The following concerns versions 2020b and 2024b.
I'm creating a code importer that parses XML to generate a model within simulink. The XML encodes regular interconnected logic gates, numerical comparitors, conditionals, etc arranged in subsystems. This all works fine. One subsystem contains a Stateflow chart and this is where I fall down.
I can create a new sf chart using the sfnew command, but this creates a new chart in a new window. I can't see anyway of telling it to create a chart object in a defined subsystem. I also can't see a way of even telling sfnew to create a new chart silently, without spawning a new window. I want to do all this in memory withou windows popping in and out of existance.
I have tried commands similar to the following,
>> modelName = 'flow_demo';
>> open_system(modelName);
>> subsystemPath = [modelName,'/Subsystem'];
>> add_block('built-in/Subsystem', subsystemPath);
>> subsystemHandle = get_param(subsystemPath, 'Handle');
>> chart = Stateflow.Chart(subsystemHandle);
but I get the following error message:
Error using Stateflow.Chart
No constructor 'Stateflow.Chart' with matching signature found.
Out of despiration I also tried add_block, but met with the error 'There is no block named 'Stateflow/Chart''
So how can I create a new stateflow chart silently, similar to 'add_block('built-in/Subsystem', subsystemPath);'?
After this point the APIs allow me to manipulate the the chart as I need.
Thanks.
Accepted Answer
More Answers (0)
Categories
Find more on Simulink Functions in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!