How to find the Process ID (PID) in matlab

조회 수: 70 (최근 30일)
Muharrem Askin
Muharrem Askin 2012년 6월 8일
답변: MathWorks Support Team 2025년 8월 18일
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일
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
William Stevenson 2013년 1월 3일
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 ?
Eddy Philippe
Eddy Philippe 2020년 6월 23일
Try [~,result] = system('tasklist');

댓글을 달려면 로그인하십시오.


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