I like your submission, and it works fine for my puposes even in R14. Using your old factor routines, as the new factor command uses a mat file (_primeslist_), which the old matlab version can not read. Is it possible to provide a compatible mat file for MATLAB R14?
But tridist should be the same as the norm from the initial point to the closest point (output from the function as PP0). Plotting it, it looks like PP0 is getting to the right spot, so there must be an issue with that particular path through the code. Notice that if you truncate the values I gave above, the correct answer is reached (i.e. if you only use 4 places past the decimal).