How to find the Process ID (PID) in matlab

62 次查看(过去 30 天)
Is there any function or method in matlab to find the process ID (PID) of the program in the task manager ?

采纳的回答

MathWorks Support Team
MathWorks Support Team 2025-8-18,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.

更多回答(5 个)

Kaustubha Govind
Kaustubha Govind 2012-6-8
There is an undocumented (but relatively well-known) function:
>> feature getpid
  2 个评论
Muharrem Askin
Muharrem Askin 2012-6-11
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 2012-6-11
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
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 2016-10-11
编辑:Jim Hokanson 2016-10-11
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 2012-6-9
  2 个评论
Muharrem Askin
Muharrem Askin 2012-6-11
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 ?

请先登录,再进行评论。


Pierre Harouimi
Pierre Harouimi 2025-6-3
Since the R2025a release, you have now the matlabProcessID function.

类别

Help CenterFile Exchange 中查找有关 PID Controller Tuning 的更多信息

标签

尚未输入任何标签。

Community Treasure Hunt

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

Start Hunting!

Translated by