Similar to the preferences which are propagated into your component, the files 'matlabrc.m' and 'startup.m' files are also included in the compilation. As in base/undeployed MATLAB, these functions are automatically run when you initialize your component.
To automatically set the number of threads used by your component, create a file named 'startup.m' in your project directory and add the following lines of code to it:
warning off MATLAB:maxNumCompThreads:Deprecated
maxNumCompThreads(1);
The first line of code suppresses the warning which is issued by calling maxNumCompThreads, and the second line actually sets the number of threads to 1.
NOTE: The maxNumCompThreads function will be removed in a future version of MATLAB. See the official function Help for more information:
https://www.mathworks.com/help/matlab/ref/maxnumcompthreads.html
Best Answer