Borrar filtros
Borrar filtros

persistent variables are reinitialized ?

3 visualizaciones (últimos 30 días)
sali
sali el 15 de Sept. de 2015
Editada: per isakson el 15 de Sept. de 2015
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,

Respuestas (1)

Walter Roberson
Walter Roberson el 15 de Sept. de 2015
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.

Categorías

Más información sobre Simulink Functions en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by