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

45 次查看(过去 30 天)
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 个评论
James
James 2011-9-28
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 2011-9-28
It seems to be when a .m file being run calls others to run with run filename

请先登录,再进行评论。

采纳的回答

James
James 2011-9-29
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 个评论
Daniel Shub
Daniel Shub 2011-9-29
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 2011-9-29
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 :)

请先登录,再进行评论。

更多回答(3 个)

Daniel Shub
Daniel Shub 2011-9-28
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 个评论
James
James 2011-9-29
rmdir is being used to remove a directory autogenerated by another command. Thanks for the suggestion, but it's always successful.

请先登录,再进行评论。


Peter Barsznica
Peter Barsznica 2016-1-19
  1 个评论
James
James 2016-1-20
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.

请先登录,再进行评论。


swathi anil
swathi anil 2020-3-24
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

类别

Help CenterFile Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by