How to find the Process ID (PID) in matlab

63 visualizaciones (últimos 30 días)
Muharrem Askin
Muharrem Askin el 8 de Jun. de 2012
Respondida: MathWorks Support Team el 18 de Ag. de 2025 a las 19:57
Is there any function or method in matlab to find the process ID (PID) of the program in the task manager ?

Respuesta aceptada

MathWorks Support Team
MathWorks Support Team el 18 de Ag. de 2025 a las 0:00
Starting in R2025a, you can obtain the PID of a MATLAB process with the MATLAB command:
>> matlabProcessID
This function returns the PID as a uint64 variable.
In earlier versions of MATLAB, you can obtain the PID of a MATLAB process with the MATLAB command:
>> feature('getpid')
This returns the PID as a double variable. Please note that the use of the "feature" function is undocumented, meaning that it can be removed or changed at any time.

Más respuestas (5)

Kaustubha Govind
Kaustubha Govind el 8 de Jun. de 2012
There is an undocumented (but relatively well-known) function:
>> feature getpid
  2 comentarios
Muharrem Askin
Muharrem Askin el 11 de Jun. de 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 el 11 de Jun. de 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.

Iniciar sesión para comentar.


William Stevenson
William Stevenson el 3 de En. de 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 el 11 de Oct. de 2016
Editada: Jim Hokanson el 11 de Oct. de 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 el 9 de Jun. de 2012
  2 comentarios
Muharrem Askin
Muharrem Askin el 11 de Jun. de 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 el 23 de Jun. de 2020
Try [~,result] = system('tasklist');

Iniciar sesión para comentar.


Pierre Harouimi
Pierre Harouimi el 3 de Jun. de 2025
Since the R2025a release, you have now the matlabProcessID function.

Etiquetas

Aún no se han introducido etiquetas.

Community Treasure Hunt

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

Start Hunting!

Translated by