Static variables in MATLAB
131 次查看(过去 30 天)
显示 更早的评论
How do I declare static variable in MATLAB?
0 个评论
采纳的回答
Abhishek Jain
2016-10-6
编辑:madhan ravi
2018-11-11
Use keyword persistent to declare static variables
persistent x;
0 个评论
更多回答(1 个)
Adam
2016-10-6
You can use persistent variables if that is what you mean, but only use them if you really need to. Similar to global variables they are far easier to introduce bugs into your workspace with then simply passing variables around between functions or using a class to define the scope of a variable.
1 个评论
Ravi Singh
2020-4-23
Hi Adam ,
I need to assign a static variable in one method call and use the same variable in another method call is there any way to do so ?
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Entering Commands 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!