- https://www.mathworks.com/help/stateflow/ug/adding-data.html
- https://www.mathworks.com/help/stateflow/ug/access-data-store-memory-from-a-chart.html
Is it possible to declare a persistent variable in a Stateflow subchart?
11 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hi!
I'm using a Stateflow chart to generate some code (C action language). I would like to declare a subchart variable as persistent (or static), so the value is remembered the next time the subchart is executed.
A solution is to attach this variable to one of the parent states, but then this variable is visible to all the subcharts, which is not ideal.
Another solution is to create an embedded Matlab function with persistent variables on it, but this is too cumbersome, since I would need to read all the variables in the beginning and write them before leaving the state.
Is there a simpler way to achieve this?
0 comentarios
Respuestas (1)
Ayush
el 13 de Sept. de 2023
Hi Marcos,
I understand that you want to declare a persistent variable in a Stateflow sub chart.
It can be achieved by using the “Data Store Memory” block in Simulink which enables the use of a persistent variable by binding the scope of your Stateflow data object to an independent memory region.
Please refer to the below documentations to know more about the workflow involved in integrating a “Data Store Memory” block to your Stateflow Chart:
I hope it helps,
Regards,
Ayush Misra
0 comentarios
Ver también
Categorías
Más información sobre Simulink Functions en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!