MATLAB: Do I receive the error Unable to read file ‘‘. No such file or directory in MATLAB Workers

addattachedfilesdirectoryfilenoParallel Computing Toolboxparpool

I would like to load some MAT files and do some operations.
But, when I do it in parallel, I get the following error-
Unable to read file 'mockdata.mat'. No such file or directory.
How to fix this?

Best Answer

Use addAttachedFiles if you would like to access files from workers.
'addAttachedFiles' adds extra attached files to the specified parallel pool. These files are transferred to each worker and are treated exactly the same as if they had been set at the time the pool was opened — specified by the parallel profile or the 'AttachedFiles' argument of the parpool function.