quit doesn't close the program - process still running in task manager

43 visualizzazioni (ultimi 30 giorni)
When I run the quit command in the command window or in a script, the application appears to close, but opening the Task Manager I find that there is still a process there taking up a large proportion of the CPU and memory named MATLAB.exe
It seems that it's still running in the background?
  4 Commenti
James
James il 28 Set 2011
Thanks Jan.
I've ran a script with just the first 4, and that went fine. Running a script with the last 3 does fine too.
But when the first script calls the second at the start, it seems to fail to quit properly.
James
James il 28 Set 2011
It seems to be when a .m file being run calls others to run with run filename

Accedi per commentare.

Risposta accettata

James
James il 29 Set 2011
Splitting my script into two, with the first one handling a lot of code generation and ending with a quit, always worked fine. The second script ran tests, and ended with a quit, which has always worked fine.
Any integration of these scripts, either into a single script, or into a parent and child script (i.e. one invokes the other) caused problems with Matlab not closing properly.
It's very curious, but there must be some kind of interference between some commands that doesn't allow Matlab to close properly.
This isn't really a solution, but I'd posted the question in the hope someone knew how to force a close in some way, or perhaps had experience of the problem.
  2 Commenti
Daniel Shub
Daniel Shub il 29 Set 2011
If they are scripts and not functions, you should be able to take the first line of the second script and add it to the end of the first script. Run that new script and see if you can quit. If you can, restart MATLAB and add the next line to the first script. At some point it will crash (i.e., not let you quit). Then you need to start pairing down the lines at the beginning. Once you have a MWE that repeatably reproduces the problem, you will probably see the solution. If not post the MWE here.
James
James il 29 Set 2011
I've had a go at something like that, but it's very inconsistent. The same script can be run multiple times and it won't always fail to close properly (sometimes it consistently works when run from within matlab, but consistently fails to close if it's run from the command line).
A bit hard to reduce to the problem code when it's tempermental.
Thanks though :)

Accedi per commentare.

Più risposte (3)

Daniel Shub
Daniel Shub il 28 Set 2011
I am not sure what happens with MATLAB and rmdir if it fails to remove the directory (for example because of file permissions) it may cause MATLAB to hang. Really though you haven't given us enough to know what it happening. It is just going to be a painful line-by-line quit in between debug.
  1 Commento
James
James il 29 Set 2011
rmdir is being used to remove a directory autogenerated by another command. Thanks for the suggestion, but it's always successful.

Accedi per commentare.


Peter Barsznica
Peter Barsznica il 19 Gen 2016
  1 Commento
James
James il 20 Gen 2016
That is unrelated. This question is to do with a Matlab script that exits Matlab when it's done, yet Matlab continues to run.
Taskkill might work, although it seems like a bit of a brutal way to exit an application. It would take a bit more work if multiple instances of Matlab are running to ensure the correct one is killed.

Accedi per commentare.


swathi anil
swathi anil il 24 Mar 2020
Hi James,
I was facing a similar problem, not being able to exit my matlab gui figures or even the matlab window at all.
Using
quit force
worked in this case. I would recommend going through the quit command variants in the following link, to pick the one that suits your scenario:
https://de.mathworks.com/help/matlab/ref/quit.html#d120e1010208

Categorie

Scopri di più su Startup and Shutdown in Help Center e File Exchange

Prodotti

Community Treasure Hunt

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

Start Hunting!

Translated by