MATLAB: Eval/publish routines use data from cache

evalpublish

I am trying to use the publish function to generate reports, and the problem is that the function seems to use a cached version on the .m file. I wrote a function F.m that generates the script S.m (which has code that creates graphical objects etc), and I am passing the S.m script to the publish() function to do its publishing. However, when I update my F.m function that generates the S.m script, the graphics does not update/change. It appears that Matlab uses some cached version of the S.m script, rather than the new (updated) one. Instead of using the publish() function, I used the eval() function just to try things out, but the eval() function behaves the same way.
What is the problem? If I open the S.m file in some editor I see that the changes were updated properly. But the resulting graphics do not reflect it. Why is this?
Boris

Best Answer

If you modify a .m file that will be later executed, you need to "clear" the function of the same name as the .m file to invalidate the JIT cache.
Related Question