Could somebody help me to implement an algorithm with stateflow?

3 views (last 30 days)
I would like to implement an algorithm to charge or discharge my energy storage system with two loops. Could you please help me to do this with stateflow or with matlab code? thank you!

Answers (2)

Apeksha Bagrecha
Apeksha Bagrecha on 20 Sep 2022
The idea would be to retain the information of the variables in a state between time steps and then use that information to add or shift elements accordingly. There are various ways of doing it and one possible approach would be to call Graphical Functions in States, where in each call to the function, the entire loop is executed and data written to the array accordingly.
The attached example (testRingBuffer_TS.slx) implements a ring buffer of size 5 using the graphical function in states of a Stateflow chart.
Additional information on Graphical Functions can be found at our documentation page
>> web(fullfile(docroot, 'stateflow/flow-graph-algorithm.html'))

Benjamin Thompson
Benjamin Thompson on 19 Sep 2022
Please start with the Stateflow Onramp Training on the Mathworks website. Then try to implement your algorithm and if you have specific problems post a new question with sample files attached.

Categories

Find more on Complex Logic in Help Center and File Exchange

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!