MATLAB: How to set file dependencies in the deployed code that uses Parallel Computing Toolbox 5.0 (R2010b) functions

computingdependenciesdeployedfileparallelParallel Computing Toolboxtoolbox

I am compiling my MATLAB code to be run on a cluster using MDCS, into a Java component. I included the following piece of code in my MATLAB program to add file dependencies to my job.
set(job1, 'FileDependencies',{'C:\MyDirectory\fileName.m'});
By giving this absolute path of the file as file dependency, the code runs fine with the correct outputs on MATLAB. However, when I try to run the deployed version of this code, the job does not run and the result vector is empty as if the job did not execute.

Best Answer

This behavior is seen because the deployed code is trying to access the original unencrypted version of the file filename.m . In order to avoid this issue, add the file filename.m as an additional file in the CTF archive using -a flag of mcc command or add the file as an additional file in the deploytool project.
Modify the MATLAB code to include the following:
if(isdeployed)
set(jobHandle, 'FileDependencies',{'fileName.m'});
else
set(jobHandle, FilleDependencies',{'C:\MyDirectory\fileName.m'});
end
This enables the deployed code to access the encrypted file that it needs from the current CTF directory specified in the IF part. The MATLAB code continues to access the original file from the absolute path specified in the ELSE part.