There's an old 2013 question (https://www.mathworks.com/matlabcentral/answers/106531-how-to-get-matlab-to-reload-an-m-file) related to this. The answer back then suggests that MATLAB is not checking for changes. However, up until 2020a, this has never been an issue for me, so something new has changed with 2020b. I'm hoping this can be reverted. Issuing clear myscript before every call is not feasible, especially with large projects with subroutines upon subroutines.
MATLAB 2020b does not reload .m file edited outside of matlab until after running
5 次查看(过去 30 天)
显示 更早的评论
I typically edit .m files outside of the matlab ide (using vim). Up until 2020b this was never an issue. In 2020b, if I make a change to a script or function, then the next time I run it in matlab it will use the old version. If I run it a second time, it will have noticed the changed file and run the new version.
To recreate this consistently:
In Terminal.app:
echo "fprintf('old version\n')" > myscript.m
In MATLAB:
myscript
displays:
old version
In Terminal.app
echo "disp('new version');" > myscript.m
In MATLAB:
myscript
displays
old version
Again in MATLAB:
myscript
displays
new version
In Terminal.app
rm myscript
In MATLAB
myscript
displays
new version
Again, in MATLAB:
myscript
displays
Unrecognized function or variable 'myscript'.
Is there a way to fix this in settings somehow? This is making 2020b almost unusable for me. Will there be an update before the official release to fix this?
回答(1 个)
Steven Lord
2020-8-19
Release R2020b has not been released yet, so I suspect you're using the Prerelease of R2020b. Please send questions or feedback on Prerelease versions to Technical Support using the telephone icon in the upper-right corner of this page instead of posting them to MATLAB Answers.
3 个评论
Steven Lord
2020-8-19
The answer is not as simple as yes or no, as you can see from the fact that there is a documentation page on the subject for Windows as well as one that described caching of files on the MATLAB path (which is one reason we recommend users not put files in directories under matlabroot.) You should probably provide details about your configuration (OS, which I suspect from your comment is macOS, as well as whether you're putting these files on a local or network drive) to Technical Support.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Startup and Shutdown 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!