Persistent variable clear after simulation with simulink
18 ビュー (過去 30 日間)
古いコメントを表示
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
persistent var
if isempty(var)
var= 1
end
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)
0 件のコメント
採用された回答
Sebastian Castro
2016 年 5 月 25 日
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.
- Sebastian
2 件のコメント
Walter Roberson
2016 年 5 月 26 日
I would gather from this that a "clear" is being one at some point ?
Though if it is one of the Accelerator modes then you are probably running a complete executable...
その他の回答 (1 件)
参考
カテゴリ
Help Center および File Exchange で Naming Conventions についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!