Persistent variable clear after simulation with simulink
14 views (last 30 days)
Hello, i have a problem, where I need help. I have decleared and initilized a persistent variable var in a Matlab Embedded Function in Simulink. For example
I noticed that the variable doesn't exist after the simulation end's. Thats why var is initialized again, when i start a simulation. Is this normal ? (I don't have any function in Model Property)
Sebastian Castro on 25 May 2016
Yes. This is normal.
The persistent variable will persist between time steps of the simulation, i.e., between calls to the MATLAB Function. At the end of simulation, the variable will go out of scope.
What exactly are you trying to do between simulations with such a variable? Maybe there's another way.