check if an external application is running or not from matlab
10 次查看(过去 30 天)
显示 更早的评论
I have an application opened from Matlab. I would like to check if the instance of the application is running or not from Matlab. If the application instance is running I would like to bring the window into focus and perform certain actions. Considering the external application as Notepad please let me know if this can be done. I tried using wscript shell COM component and the appactivate method in it, but no use. I am sure that this can be done using Java commands from Matlab, but not very familiar with Java though.
Thanks in advance. Krishna.
0 个评论
采纳的回答
Jason Ross
2011-10-3
3 个评论
Matthew
2013-5-6
Do you have a solution for this on MAC OS X? Running apps are indicated in the 'force quit' screen and in the activity monitor, but I need Matlab (2012a) to know if an app is running or not.
Jason Ross
2013-5-6
On UNIX systems this is actually quite easier since the shell provides a lot of utilities that work really well together. For example,
pgrep matlab | wc -l
or
ps -ef | grep matlab | wc -l
will give you a count of the number of MATLAB processes running. Change what you are grepping for if you need to. On Mac, the options of ps may be a little different (it might be ps -A), but you can tweak it as you need to.
What's happening here is that the "pgrep matlab" or "ps -ef | grep matlab" parts give a list of processes that have "matlab" in them, and then the "wc -l" (wc = word count) counts the number of lines.
There are also shell commands that can easily give you your process ID, and you can tell from the process table which processes started what. You can get this same information on Windows, but it takes more work or a utility like the PS Tools to get at it.
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Call Java from MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!