How to find the Process ID (PID) in matlab
59 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Muharrem Askin
le 8 Juin 2012
Réponse apportée : MathWorks Support Team
le 18 Août 2025 à 19:57
Is there any function or method in matlab to find the process ID (PID) of the program in the task manager ?
0 commentaires
Réponse acceptée
MathWorks Support Team
le 18 Août 2025 à 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.
0 commentaires
Plus de réponses (5)
Kaustubha Govind
le 8 Juin 2012
There is an undocumented (but relatively well-known) function:
>> feature getpid
2 commentaires
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.
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"')
0 commentaires
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
0 commentaires
Voir également
Catégories
En savoir plus sur PID Controller Tuning dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!