persistent variables are reinitialized ?
조회 수: 7 (최근 30일)
이전 댓글 표시
Dear all, I have a system which contains many subsystems each of them has a Matlab function block with its own persistent variables I display the variables during the run which usually takes hours, what I found that after a certain point all the persistent variables are reinitialized to its starting values! I do not know why?
I was looking for a solution I found that I should use mlock but it does not work in the matlab function block!, I added
coder.extrinsic('mlock');
mlock();
but I am getting this error
Call to MATLAB function aborted: "MLOCK" must be called from a file.
Component: Stateflow | Category: N.A.
Could you please help me solving this issue. Thank you,
댓글 수: 0
답변 (1개)
Walter Roberson
2015년 9월 15일
Generally speaking, persistent variables are reinitialized if the function they are in is ever cleared, either by way of an explicit
clear TheFunctionName
or by a
clear all
There may be some situations in Simulink or SimScape that I am not familiar with in which a clear is done. (For example it would not startle me if disabling a block or subsystem had that result.)
Please check your blocks for "clear" statements. If you find any "clear all" then you should definitely remove those statements.
댓글 수: 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!