MATLAB throws "Operation terminated by user" by itself
82 views (last 30 days)
I have recently installed MATLAB R2021b, and I am facing a problem that I have not had before (with other MATLAB versions).
I have realised that when running two instances of MATLAB with the same script, MATLAB stops with a "Operation terminated by user" message. Of note, the script is the same but slightly modified, e.g. modifying one line like this
files_path = "D:\Path\To\Files\FolderA"
files_path = "D:\Path\To\Files\FolderB"
The first MATLAB instance runs with no problem, but just when running the second instance, the first one stops with the "Operation terminated by user" message. By investigating a bit more, I have realised that it seems to be related with modifying the script and saving it, not with running the script itself (remember that when a script is ran, it is automatically saved). I also think that it is probably related with having the first instance minimized or maximized in background....
Its a bit difficult to assess this problem, as it do not always happen, and repeating the same actions some times yield to an error and others do not (it throws the error about a 50% of the times).
PS: I think that is not related with the function that MATLAB runs.
Does anybody knows something about this issue?
Thank you in advance.
Kumar Pallav on 26 Nov 2021
I understand that you are facing a problem when trying to run several instances of MATLAB processes executing the same script.
Please note that the above behaviour is a known bug in MATLAB R2021b. This has already been communicated to the developers and we are working actively on fixing the bug.
As for now there are two potential workarounds:
1. You can try to uncheck the “Reload unedited files that have been externally modified” option in Preferences>Editor/Debugger and then try again. However, this will open a dialog box asking to reload the file each time you open a script in a new MATLAB instance.
2.The second one is to open the script in an external IDE (such as VSCode) and modify the script from there. VSCode in particular allows you to have documents autosave changes, so you can easily make modifications to the same script while others are running without having to repeatedly save the script manually. The biggest drawback, however, is that you will not have access to the tools and features that MATLAB’s in-built script editor has.