Persistent

The persistent keyword is used to declare a variable as persistent. A persistent variable is local to a function (like a normal variable), but its value is retained between function calls. It is initialized to an empty matrix.

function c=counter
      persistent count
      if isempty(count)
            count = 1
      else
            count = count+1
      end
      c=count
end
counter()
counter()
counter()
disp(counter())

The value of printed out by this code snippet is 4.