This is the expected behavior when using a PARFOR loop in a compiled application. When you start a MATLABPOOL, all the workers "cd" to the client's working directory which in this case is the "C:\Work" directory. When the worker needs to evaluate the shared library function "mlfParforTest", it looks for a file called "parforTest.m", finds it in the current directory and tries to run it. However, since this function is not the compiled version, the worker fails and the error is obtained.
However, if the client, and therefore, the workers are in a different directory when the application starts then this error does not occur. The above mentioned workaround can be used if the workers are on the local machine.
If the workers are on a different machine, then to ensure that this file is available to all the workers, specify FileDependencies when opening a MATLABPOOL as shown below:
matlabpool('open', 'FileDependencies', {'parforTest.m'});
This will ensure that all the workers will have the file.
Best Answer