Why is my variable not staying updated in Simulink
27 ビュー (過去 30 日間)
古いコメントを表示
Hello,
I am using Simulink and have a variable set to zero in an enabled subsystem. I send the signal out of the subsystem and am trying to update it as x = x + 1 where x is the signal. After simulink goes through all the blocks once and gets back to where x = x + 1 the x is reset to 0. I have a breakpoint in the enabled subsystem where I initialized it and it never goes back there. Any ideas would be appreciated. Thank you!
2 件のコメント
Kaustubha Govind
2013 年 6 月 18 日
Could you please explain what block(s) you use to implement the x=x+1 part?
採用された回答
その他の回答 (1 件)
Erwin Torreao Dassen
2013 年 6 月 18 日
編集済み: Erwin Torreao Dassen
2013 年 6 月 18 日
Is this a custom matlab function block? In that case try declaring the variable persistent. (UPDATED)
3 件のコメント
Erwin Torreao Dassen
2013 年 6 月 19 日
I'm not sure I understand what you trying to achieve. My guess of what is happening is that your matlab-function block that defines x = 0 is being used as input outside the subsystem. If that is the case the first block outside this subsytem will always receive 0 as input signal and it will never output more than 1... In fact, your matlab-function block is just a "constant" block.
What is the behavior you want to obtain?
Regards, Erwin
参考
カテゴリ
Help Center および File Exchange で Event Functions についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!