MATLAB: Matlab Crushes when new .m file is added

crushesMATLABrebootundefined function

Whenever I add a new .m file in the current folder, Matlab doesn't automatically recognize it and it prompts me to either change folder or add to path and then it just comes the error " Undefined Function" although the function exists at the working folder.
I have to shut down Matlab and reboot it in order to recognize it.
Any ideas why is this happening? Thanks

Best Answer

This is not a crash, nor even a crush. It is just that MATLAB caches the files in the MATLAB directories. It does this to enhance speed, pre-processing those files when it starts up. Therefore MATLAB does not watch those directories, not expecting any changes in them. This is why things "work" again for you when you restart, because MATLAB cached your changed files.
That means the solution is that you should NOT be using those directories! Do NOT save your files into the supplied directories. Instead, add your own directories to the search path. You can save files to your own directories with no problem at all.
Related Question