- 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 (최근 30일)
이전 댓글 표시
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
답변 (1개)
Ayush
2023년 9월 13일
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
참고 항목
카테고리
Help Center 및 File Exchange에서 Simulink Functions에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!