Static variables in MATLAB

128 次查看(过去 30 天)
How do I declare static variable in MATLAB?

采纳的回答

Abhishek Jain
Abhishek Jain 2016-10-6
编辑:madhan ravi 2018-11-11
Use keyword persistent to declare static variables
persistent x;

更多回答(1 个)

Adam
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
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 CenterFile Exchange 中查找有关 Entering Commands 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by