Effacer les filtres
Effacer les filtres

Static variables in MATLAB

156 vues (au cours des 30 derniers jours)
Anirudh Sharma
Anirudh Sharma le 6 Oct 2016
Commenté : Ravi Singh le 23 Avr 2020
How do I declare static variable in MATLAB?

Réponse acceptée

Abhishek Jain
Abhishek Jain le 6 Oct 2016
Modifié(e) : madhan ravi le 11 Nov 2018
Use keyword persistent to declare static variables
persistent x;

Plus de réponses (1)

Adam
Adam le 6 Oct 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 commentaire
Ravi Singh
Ravi Singh le 23 Avr 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 ?

Connectez-vous pour commenter.

Catégories

En savoir plus sur Entering Commands dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by