MATLAB: How to save the variables x and fval when using [x,fval] = fmincon() in a parfor

fminconparfor

I get the following error:
An UndefinedFunction error was thrown on the workers for 'x'. This might be because the file containing 'x' is not accessible on the workers. Use addAttachedFiles(pool, files) to specify the required files to be attached. See the documentation for 'parallel.Pool/addAttachedFiles' for more details.

Best Answer

parfor K = ....
[x{K}, fval{K}] = fmincon(.....)
end
Related Question