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

22 次查看(过去 30 天)
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.
  1 个评论
mukthi
mukthi 2024-5-1
can anyone say, iam able to save my file but i can just save in matlab in matlab drive ,iam not able to save my life into my laptop(like windows downloads documents etc )

请先登录,再进行评论。

类别

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