Another possibility, which I use quite often: use an auxiliary script (m-file) instead of a function. The main script does the precomputing and then calls the auxiliary script.
The auxiliary script has visibility of all variables defined in the calling script, so you don't need global or persistent variables, which probably introduce some overhead in terms of running time.
Of course, you need to take care that the variables in the auxiliary script do not overwrite anything they shouldn't in the main script. That is, you need to prevent clashes in the names of the variables between the two scripts.