FUNCTION REFERENCE

persistent

Retain a function variable between calls.

Retain a function variable between calls.

Syntax

persistent name1 name2

Declarations are allowed only inside functions. clear functionName resets saved values.

Example

a=tick(); b=tick(); [a b], function y=tick(), persistent n; if isempty(n), n=0; end; n=n+1; y=n; end   % [1 2]

Differences from MATLAB: Persistent storage is bounded by the engine's workspace limits.

These are the engine’s help pages. Each page keeps its compatibility notes. File operations are unavailable in the browser.