How to find the Process ID (PID) in matlab

126 vues (au cours des 30 derniers jours)
Muharrem Askin
Muharrem Askin le 8 Juin 2012
Commenté : Eddy Philippe le 23 Juin 2020
Is there any function or method in matlab to find the process ID (PID) of the program in the task manager ?

Réponses (4)

Kaustubha Govind
Kaustubha Govind le 8 Juin 2012
There is an undocumented (but relatively well-known) function:
>> feature getpid
  2 commentaires
Muharrem Askin
Muharrem Askin le 11 Juin 2012
Actually I would like to get the PID of another programs when they are running at the time I check it. Simply, I would not only want to get the PID of matlab but also the others listed on the task manager. Do you know how can I do that ?
Kaustubha Govind
Kaustubha Govind le 11 Juin 2012
I think you might need to figure out a Windows shell command that does that and use the SYSTEM function to call into the shell.

Connectez-vous pour commenter.


William Stevenson
William Stevenson le 3 Jan 2013
To find the running tasks: [response,tasks] = system('tasklist');
e.g. to find Excel [response,tasks] = system('tasklist/fi "imagename eq Excel.exe"')

Jim Hokanson
Jim Hokanson le 11 Oct 2016
Modifié(e) : Jim Hokanson le 11 Oct 2016
A .NET solution:
name = 'excel'; %for example
p = System.Diagnostics.Process.GetProcessesByName(name);
if p.Length == 1
pid = p(1).Id; %You must index into p (not p.Id), as this changes the class type
end

Yair Altman
Yair Altman le 9 Juin 2012
pid = feature('getpid')
  2 commentaires
Muharrem Askin
Muharrem Askin le 11 Juin 2012
Actually I would like to get the PID of another programs when they are running at the time I check it. Simply, I would not only want to get the PID of matlab but also the others listed on the task manager. Do you know how can I do that ?
Eddy Philippe
Eddy Philippe le 23 Juin 2020
Try [~,result] = system('tasklist');

Connectez-vous pour commenter.

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by