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?
  2 个评论
Alec Jacobson
Alec Jacobson 2020-8-19
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.
Alec Jacobson
Alec Jacobson 2020-8-20
For other people landing here. Tech Support got back to me that this is a known issue that they're working on but might not be fixed by the 2020b general release. In the meantime, typing clear functions is supposed to reload everything (rather than clear myscript one at a time).

请先登录,再进行评论。

回答(1 个)

Steven Lord
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
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.
Alec Jacobson
Alec Jacobson 2020-8-19
Yup, mac OS and local drive on a laptop. By not putting files in matlabroot do you mean not putting them in the '/Applications/MATLAB_R2020b.app' directory? If so, then they're definitely not there. FWIW, toggle Enable toolbox path cache in general settings did not fix this issue.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Startup and Shutdown 的更多信息

产品


版本

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by