Static variables in MATLAB

239 visualizaciones (últimos 30 días)
Anirudh Sharma
Anirudh Sharma el 6 de Oct. de 2016
Comentada: Ravi Singh el 23 de Abr. de 2020
How do I declare static variable in MATLAB?

Respuesta aceptada

Abhishek Jain
Abhishek Jain el 6 de Oct. de 2016
Editada: madhan ravi el 11 de Nov. de 2018
Use keyword persistent to declare static variables
persistent x;

Más respuestas (1)

Adam
Adam el 6 de Oct. de 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 comentario
Ravi Singh
Ravi Singh el 23 de Abr. de 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 ?

Iniciar sesión para comentar.

Categorías

Más información sobre Entering Commands en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by