Hi Ganesh,
I understand that you are facing difficulties in creating a loop with certain conditions in Stateflow. The issue you are experiencing is likely due to the usage of junctions, which causes the entire loop to be simulated in a single time step. To resolve this, I recommend replacing the junctions with states.
Using states instead of junctions ensures that there can only be one transition between states in a single time step, whereas multiple transitions can exist between junctions. This change will help you achieve the desired behavior for your loop.
Refer to the example below to implement the loop:
Note that not all junctions are replaced with states in this example, as doing so would result in multiple time steps for a single iteration.
Additionally, you can utilize the "after" function to introduce delays between states. This simplifies the implementation of delays without the need for complex timer and loop logics. An alternative implementation of your model without any timer logic using the "after" function is shown below.
Refer to the following MATLAB documentation to get more details about the "after" function:
I hope this addresses your query.
Best Regards
Yash