check if an external application is running or not from matlab

9 views (last 30 days)
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.

Accepted Answer

Jason Ross
Jason Ross on 3 Oct 2011
  3 Comments
Matthew
Matthew on 6 May 2013
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
Jason Ross on 6 May 2013
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.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!