How to trigger a State Chart using multiple function calls?

8 次查看(过去 30 天)
I have a Stateflow Chart that has to be executed when either of my two/three function calls is made (I can alter the model to make sure only one function call happens at a time.)
From what I gathered till now from my online reading, a statechart can only have one input event port. So, I tried using a Mux (a Merge and a Bus Creator too) as suggested here. Might be because that functionality being discontinued in R2021a or so (I am not sure), I wasn't able to make it work still.
The test model image below describes the logic that I am trying to create.
Both the enabled subsystems just outputs a continuous function call throughout their active period.
The error I received from the above model:
Port width mismatch. Chart is expecting input events signal of length 1. The actual input events signal has length 2.
Component: Simulink | Category: Model error
Error occurred in 'test/Chart1'.
Component: Simulink | Category: Model error
NB: The model I am building is bound to be auto-converted into C code (Embedded Coder). So do mention if any of the stuff mentioned here or those in your solution affects that.

采纳的回答

Deepu George Kurian
Never mind. I just figured it out.
The Mux works fine, just as shown in the image or the link I shared before (in question description). I just had to define the required number of Input Events within the statechart; the same number as the number of function-calls connected through the Mux (previously I had defined only one). All of these input events will be taken from the same port, which could cause confusion (as it did in my case)

更多回答(0 个)

类别

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

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by