MATLAB: How to determine how many sessions of MATLAB are open

instancesMATLABsession

I would like to know how many sessions of MATLAB are open.

Best Answer

On Unix, execute the following commands:
[ret_val,task_str]=system('ps'); %get list of applications
number_matlab_sessions=length( regexp(task_str,'MATLAB') ) %search for MATLAB in string
On Windows, execute the following commands:
[ret_val1,task_str1]=dos('tasklist');
number_matlab_sessions1=length( regexp(task_str1,'MATLAB') )