I want to create a logic with Subsystems in Simulink like Stateflow without using state machine. What are the alternatives to Stateflow?
Show older comments
Hey everyone,
I want to create a logic with Subsystems in Simulink like a State Machine without using state machine. What are the alternatives to State machine? I would be happy, if you guys help me to this topic. Thanks a lot.
7 Comments
Fangjun Jiang
on 10 Mar 2023
What type of logic? If there is no state, then it usually can be done with blocks.
If there are states, then the alternative is to write a code to implement the state machine.
Ihsan
on 14 Mar 2023
Fangjun Jiang
on 14 Mar 2023
The "block" you mentioned above, do you refer it as the "state" box in a Stateflow chart, or do you refer it as a Simulink block in a Simulink library, or is it something in your physical system that you want to simulate?
Yes. You can use the MATLAB Function block to write .m code to implement a state machine.
Ihsan
on 14 Mar 2023
Fangjun Jiang
on 15 Mar 2023
"first get one block active and if the conditions are done in first block, the second block must be active"
This can be done with enabled subsystem block.
"The system must jump from one block to another depending on conditions."
Not sure what you mean by "jump" between subsystem blocks.
In Stateflow, a "jump" usually means a transition, which can be triggered by a condition and can trig an action. When completed, the transition makes the active state jump from one state to another.
Ihsan
on 15 Mar 2023
Fangjun Jiang
on 15 Mar 2023
Use the approach suggested by @Oguz Kaan Hancioglu below, I think you can achieve activating and de-activating subsystems based on conditions. The transition action may be hard to implement but you may not need it.
Answers (1)
Oguz Kaan Hancioglu
on 15 Mar 2023
0 votes
You can use the switch case block in Port-Subsystem in Simulink Library. You can use the switch case block with the Switch Case action subsystem to make state machine in simulink enviment without Stateflow. You may need to keep in memory the state variable of your state machine.
As a reminder, simulink implements your state machine as a time based system. Stateflow is event triggered system. There is a difference.
Best
3 Comments
Ihsan
on 15 Mar 2023
Fangjun Jiang
on 15 Mar 2023
They are the same in terms of multiple choice. But since you need to activate/deactivate subsystem block, Switch-case is ready to be used with the action subsystem block.
Ihsan
on 15 Mar 2023
Categories
Find more on General Applications 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!