persistent variable_name
persistent('variable_name')
persistent variable_name1, ..., variable_nameN
| Parameter | Description |
|---|---|
| variable_name | 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 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
for i = 1:30
r = test_persistent_function();
end
| Version | Description |
|---|---|
| 1.0.0 | initial version |