필터 지우기
필터 지우기

Start Simulink sim with persistent variables, using stored state

조회 수: 3 (최근 30일)
Leena Singh
Leena Singh 2023년 2월 15일
댓글: Paul 2023년 2월 16일
I have a simulink simulation with matlab function blocks that contain persistent variables.
Since switching to Matlab R2022, (from R2021a) I have been unable to start my Simulink sim from a saved state and have have the persistent variables populated. Is there something particular that needs to be done to save the persistent variables? These revert to the null vector when starting from a saved state.
  댓글 수: 5
Leena Singh
Leena Singh 2023년 2월 16일
Yes, i think i am going to have to try that route. thanks anyhow!
Paul
Paul 2023년 2월 16일
I should have suggested to also check the Bug reports as well.
If you do contact Tech Support, would you mind posting back here summarizing the response? Probably of interest to others using the Model Operating Point feature.

댓글을 달려면 로그인하십시오.

답변 (1개)

Sulaymon Eshkabilov
Sulaymon Eshkabilov 2023년 2월 15일
Suppose that you have followed these guides with the persistent variable initialization in your model: DOC
  댓글 수: 1
Leena Singh
Leena Singh 2023년 2월 15일
Yes, the initialisation does conform to the guidelines. However, to be clear, the problem doesn't occur when the Simulink sim is first run to save the states from T= T9 to T0+1, for instance. It occurs in a subsequent run when the sim rungs from T0+1 to T0+2.
I can see (in debug mode) that the persistent variables are initialised, populated etc during the initial run. In the next run when starting using:
that the persistent variable array that had been populated is now empty.
FYI, this same code base worked as written in Matlabs R2020b and R2021a. In upgrading to R2022b, the code doesn't perform as desired as what should be a populated array of variables with history has now reverted to zero.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Naming Conventions에 대해 자세히 알아보기

제품


릴리스

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by