persistent variables are reinitialized ?
5 views (last 30 days)
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
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,
Walter Roberson on 15 Sep 2015
Generally speaking, persistent variables are reinitialized if the function they are in is ever cleared, either by way of an explicit
or by a
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.