maxNumCompThreads
Control maximum number of computational threads
Description
returns the current maximum number of computational threads.N
= maxNumCompThreads
Currently, the maximum number of computational threads is equal to the number of physical cores on your machine.
sets the maximum number of computational threads using what the MATLAB® software determines to be the most desirable. It additionally returns the
previous maximum number of computational threads, LASTN
= maxNumCompThreads('automatic')LASTN
.
Note
If you set the maximum number of computational threads using
maxNumCompThreads
, the change does not persist across MATLAB sessions.
Examples
Input Arguments
Output Arguments
Tips
To limit MATLAB to a single computational thread, you can use the
-singleCompThread
option when starting MATLAB at the system prompt:matlab -singleCompThread
. By default, MATLAB uses the multithreading capabilities of the computer on which it is running.On machines running Windows® 11 (or later) or Windows Server 2022 (or later) with multiple processor groups, the default maximum number of computational threads depends on the version of MATLAB you are using.
MATLAB R2025a and later — The default maximum number of computational threads is the number of physical cores across all processor groups.
MATLAB R2024b and earlier — The default maximum number of computational threads is the number of physical cores within the processor group that is running MATLAB.
Version History
Introduced in R2007b