Why aren't my Simulink functions being called properly when using nested Simulink functions, Stateflow charts, and Data Store blocks?

8 views (last 30 days)
I used three subsystems: one subsystem contains a Stateflow chart, which includes the state. The other two subsystems contain Simulink functions, each with its own Stateflow block. I am using nested Simulink functions, and I am calling them through Stateflow. Additionally, I used Data Store blocks, but the Simulink functions are not being called properly. why? what is the reason anyone help me on that ?

Answers (1)

Charu
Charu on 19 Feb 2025
Edited: Charu on 19 Feb 2025
Hello Kathirvel,
When dealing with Simulink functions in a Stateflow chart, especially when using nested Simulink functions and Data Store blocks, there are several potential areas that can be investigated:
-Ensure that the Data Store blocks are correctly configured and accessible by all relevant subsystems.
-Verify that the variable names used in the Data Store Read and Write blocks match those defined in the Data Store Memory block.
-Simulink functions should be defined in a way that makes them accessible from the Stateflow chart. If they are nested, ensure that their scope allows for external calls.
-Check that the function prototypes in Stateflow match those defined in the Simulink functions.
-Ensure that the Stateflow chart's execution order is correct and allows for the functions to be called in the intended sequence.
-Additionally, ensure that the data types of inputs and outputs in the Simulink functions match those expected by the Stateflow chart.
By addressing these areas, you can help ensure that your Simulink functions are called correctly, and your model operates as intended.
Hope this helps!
<Additional>
To know more about Stateflow functions you can refer to the Stateflow Onramp Course:
  1 Comment
KATHIRVEL
KATHIRVEL on 19 Feb 2025
Hi @Charu, thank you for answering me. I have attached my models and .slx file. While debugging the model, it's calling the function in Stateflow, but it only reaches the first state and doesn't return anything. Please see through the snippets for details.

Sign in to comment.

Categories

Find more on Simulink Functions in Help Center and File Exchange

Products


Release

R2024b

Community Treasure Hunt

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

Start Hunting!