Is it possible to prevent matlab from saving an m-file on "run"?

조회 수: 22 (최근 30일)
Peter
Peter 2023년 3월 13일
답변: Peter 2023년 3월 14일
Matlab saves scripts whenever they are run. I understand that this is necessary for the function of a script. It has to be saved before it can run. Fine.
But I want matlab to ask me for confirmation before saving or force me to actively press the "save" button.
My girlfriend's cat just ran over the keyboard when I wasn't looking. I ran the script...and then spend some time tracking down what had gone wrong. In the end I had to restore to a backup from yesterday. But even without the cat factor, accidents happen. You want to search for something, press "ctrl+F" and accidently touched another button and there is an unintentional change in the script. I don't want anything commited to memory unless I actively, positively tell matlab to do it. A simple confirmation dialog. "Your file has changed. Do you want to save the changes?" like Eclipse does.
I have already turned of the "Save changes upon clicking away from file"-fea...No. I refuse to call this a "feature". Anyway, I turned it off.
Is there a way to also turn of the autosave on run?

답변 (2개)

Jan
Jan 2023년 3월 13일
Of course changes can be taken back by Ctrl-Z easily, such that accidental input are no serious problem.
Even the attack of the cat would not been caught by a cofirmation dialog: If you are aware of the typing, Ctrl-Z will remove it. If you are not aware, you will confirm the dialog actively.
The reliable way to take back unintented changes is a File Version History. You find many software to do this and even Windows offers such a system. Then pressing Ctrl-S after intented changes does not need a lot of time.
A drawback: I've learned pressing Ctrl-S frequently the hard way. The editor of Matlab 5.3 crashed frequently and after 2 or 3 lines of coding I save subconsciously. Unfortunately this is not working in Matlab online, e.g. here in the forum, and so I frequently have to close the "Do you want to save this page as html file?" dialog.
Summary: An automatic history of saved files together with a frequent saving is more stable than a confirmation dialog.
  댓글 수: 2
Peter
Peter 2023년 3월 13일
While that may be true a confirmation dialog still helps in making the user aware a problem has occured. Accidential deletion of a line or a single number in a calculation may not be spotted until days later when plainly stupid results start becoming obvious.
Be that as it may, I do not consider your reply a valid answer to my question. Should somebody else have an actual solution to my problem, I would be grateful to hear it.
Jan
Jan 2023년 3월 13일
An accidental deletion of a line will not impede that you confirm the dialog for saving the file, if you are not aware of the changes. Especially if you get aware of the changes days later, such a confirmation dialog will not help in any way. Therefore I'm convinced, that the method, you are asking for, will not solve your problem, while a version history will.
This looks like a XY-problem.

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


Peter
Peter 2023년 3월 14일
I have found a workaround. Although it isn't perfect.
Matlab doesn't save files when you execute them via "Run Section" or "Run to End". And there are no rules that a script has to have more than one section. So by adding a section seperator, even if not necessary, and executing via "Run Section" instead of run, the autosave can be circumvented.

카테고리

Help CenterFile Exchange에서 Entering Commands에 대해 자세히 알아보기

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by