https://se.mathworks.com/help/optim/ug/parallel-computing-in-optimization-toolbox-functions.html
What Is Parallel Computing in Optimization Toolbox?
Minimizing Using Parallel fmincon
To minimize our expensive optimization problem using the parallel fmincon function, we need to explicitly indicate that our objective and constraint functions can be evaluated in parallel and that we want fmincon to use its parallel functionality wherever possible. Currently, finite differencing can be done in parallel. We are interested in measuring the time taken by fmincon so that we can compare it to the serial fmincon run.
options = optimoptions(options,'UseParallel',true); startTime = tic; xsol = fmincon(@expensive_objfun,startPoint,[],[],[],[],[],[],... @expensive_confun,options); time_fmincon_parallel = toc(startTime); fprintf('Parallel FMINCON optimization takes %g seconds.\n',time_fmincon_parallel);
A growing number of functions, System objects™, and features in several MATLAB® and Simulink® products offer the ability to take advantage of parallel computing resources without requiring any extra coding. You can enable this support by simply setting a flag or preference. To take advantage of this functionality on your desktop, you need Parallel Computing Toolbox™. To scale the parallel computing support to larger resources such as computer clusters, you also need MATLAB Distributed Computing Server™.