Azzera filtri
Azzera filtri

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

27 visualizzazioni (ultimi 30 giorni)
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?

Risposte (2)

Jan il 13 Mar 2023
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 Commenti
Peter il 13 Mar 2023
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 il 13 Mar 2023
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.

Accedi per commentare.

Peter il 14 Mar 2023
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 Commento
mukthi il 1 Mag 2024
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 )

Accedi per commentare.


Scopri di più su Entering Commands in Help Center e File Exchange




Community Treasure Hunt

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

Start Hunting!

Translated by