MATLAB Answers

0

Static variables in MATLAB

Asked by Anirudh Sharma on 6 Oct 2016
Latest activity Edited by madhan ravi
on 11 Nov 2018
How do I declare static variable in MATLAB?

  0 Comments

Sign in to comment.

2 Answers

Answer by Abhishek Jain on 6 Oct 2016
Edited by madhan ravi
on 11 Nov 2018
 Accepted Answer

Use keyword persistent to declare static variables
persistent x;

  0 Comments

Sign in to comment.


Adam
Answer by Adam
on 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.

  0 Comments

Sign in to comment.