A persistent variable retains its values between calls to the routine.
For example
function trial
persistent times_called
if isempty(times_called); times_called = 0; end
times_called = times_called + 1;
if mod(times_called,10) == 0
fprintf('Trial called %d times so far\n', times_called);
end
...
end
The above is just one of many uses.
Best Answer