Static variables 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

1 个投票

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 个评论

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 ?

请先登录,再进行评论。

类别

帮助中心File Exchange 中查找有关 Scope Variables and Generate Names 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by