accidentally changing built-in code from checking it by clicking on the error line

whenever an error occurs in using a built-in function, it is possible to visualize the underline code by clicking on (line ###). If, while checking, part of the code is changed accidentally (e.g. a character of the existing code is deleted, or a new character is added), does Matlab "remember" this change? Is such a change irreversible? Thank you

댓글 수: 1

If you make a change in a file in the editor and save that file, then yes, that file has been changed permanently.
Whether it is reversible depends, but in general the answer is, unfortunately, "No" unless a copy of the file has been made which a user is unlikely to have done.
It's a double-edged sword of the feature that so much of MATLAB is written in MATLAB m-file code; those files are no different than user-created ones. I've often wondered why the install doesn't mark those files as readonly so such mistakes can't happen so easily altho that makes distribution and updates more complicated for TMW.
If it has happened about the only way to recover would be to restore a copy of the function from a distribution but TMW doesn't make that an easy thing to do, either.
I think it is a weakness...
What you need to do is to be VERY careful to not CTRL-S in a system file in the editor but to cancel out and to not automatically reply yes if prompted to save the file if closing the window brings up the prompt. IS A GOOD REASON TO NOT CHECK THE AUTOMATIC "Save changes upon clicking away from a file." You can get some help if also do not check "Automatically delete backup files when the Editor closes" as then there should be a backup copy of the original.

댓글을 달려면 로그인하십시오.

 채택된 답변

Guillaume
Guillaume 2020년 3월 15일
You would have to save the file before matlab sees the changes. Additionally, on Windows if you haven't messed up with the default permissions, you would not have write permission to matlab's own directories. Also, if the file is still open you can always undo the changes.
But yes, if you do manage to change the file, you could irreversibly damage matlab.

댓글 수: 5

If you do something silly, like accidentally modify supplied code (learn to be more careful) and then save it (WHY would you do a blanket save of any changes?) then your solution is to re-download a fresh copy of MATLAB. This is not that difficult or time consuming to do.
Being a newbie in Matlab, I preferred to ask some expert users before committing such an error, which I "luckily" avoided. I expected such built-in functions not to be "changeable" just by clicking on a an error line... but now I know it. Thank you very much for all your answers.
"on Windows ... you would not have write permission to matlab's own directories"
I guess if not running as supervisor that probably is true on Windows installs, isn't it? On own system, I am and do so do need to be careful! :)
"if the file is still open you can always undo the changes."
If you haven't done a CTRL-S which empties the "Undo" buffer and has already written (if have permission, anyway).
If you notice you've made such a change before closing the file, you can undo the changes using the icons in the quick access toolbar.
"I guess if not running as supervisor that probably is true on Windows installs, isn't it?"
You mean administrator. At least, in the latest versions of Windows, the Program Files directory is not writeable even to administrator (without a UAC prompt and from a program that's running with elevated privileges. That's not normally the case with matlab.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

질문:

2020년 3월 15일

댓글:

2020년 3월 15일

Community Treasure Hunt

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

Start Hunting!

Translated by