Another approach would be to declare a persistent variable that will accumulate the results each time you call the function, and then perhaps write the results out to a MAT file the last time you call the function.
Please check the documentation:
The function template would be:
function y = foo(x)
results = zeros(...