Filter löschen
Filter löschen

Static variables in MATLAB

156 Ansichten (letzte 30 Tage)
Anirudh Sharma
Anirudh Sharma am 6 Okt. 2016
Kommentiert: Ravi Singh am 23 Apr. 2020
How do I declare static variable in MATLAB?

Akzeptierte Antwort

Abhishek Jain
Abhishek Jain am 6 Okt. 2016
Bearbeitet: madhan ravi am 11 Nov. 2018
Use keyword persistent to declare static variables
persistent x;

Weitere Antworten (1)

Adam
Adam am 6 Okt. 2016
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 Kommentar
Ravi Singh
Ravi Singh am 23 Apr. 2020
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 ?

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Entering Commands finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by