<< memory | Memory manager functions | varislock >> |
persistent variable_name |
persistent('variable_name') |
persistent variable_name1, ..., variable_nameN |
a string: variable name.
persistent defines a variable defined by his name variable_name as persistent in a function.
Before to use a persistent variable, it is necessary to initializ value.
function to define:
function r = test_persistent_function()
persistent calls;
if isempty(calls)
calls = 0;
end
disp(['nb calls to test_persistent_function: ', int2str(calls)]);
r= calls;
calls = calls + 1;
end
calls test_persistent_function
for i = 1:30
r = test_persistent_function();
end
Version | Description |
---|---|
1.0.0 | initial version |
Allan CORNET