I want to create a logic with Subsystems in Simulink like Stateflow without using state machine. What are the alternatives to Stateflow?

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

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.
Thanks for your answer!
The logic is like, first get one block active and if the conditions are done in first block, the second block must be active. The system must jump from one block to another depending on conditions. I know that is already possible with state machine but i mustn´t use state machine thats why i need an alternative.
Do you mean with the matlab function blocks in simulink?
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.
I mean a Subsystem with a Block. I want to creat a logik with subsystems without stateflow chart. Several Subsystems must work like a stateflow chart.
Do you have any advice, which only with subsystems can be done?
"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.
Yes, enabled subsystem might be a solution. Do you think, Multi Switch Port can be also used for this?
With "jump" I mean a system, which can be triggered through signals from other subsystems. And when the input signal ist not more 1 (True), it will be not more triggered.
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.

Sign in to comment.

Answers (1)

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

Thanks for your answer! Yeah thats a good point. I am thinking about to use multi switch port, in order to active different scenarios depending on different inputs. Do you think is it possible to achive that with this?
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.

Sign in to comment.

Categories

Find more on General Applications in Help Center and File Exchange

Asked:

on 9 Mar 2023

Commented:

on 15 Mar 2023

Community Treasure Hunt

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

Start Hunting!