MATLAB Answers

0

Within script function not working in parallel code

Asked by Soumyadipta Sengupta on 22 Dec 2018
Latest activity Answered by Kojiro Saito on 26 Dec 2018
if i have functions within the script, the parallel code is not working in both 2017b and 2018 on a cluster. The workers are not able to locate the functions in the script file. Although , the code works if i save the function separately ?

  0 Comments

Sign in to comment.

1 Answer

Answer by Kojiro Saito on 26 Dec 2018
 Accepted Answer

>>Although , the code works if i save the function separately?
Yes, if the function is saved as another m file, the file will be sent to a cluster automatically. If not, you can send the file to the cluster by the following codes.
p = parpool; % Use default cluster profile
addAttachedFiles(p, {'myfunc.m'}) % Send one file to the cluster
% addAttachedFiles(p, {'myFun1.m','myFun2.m'}) % Send two files to the cluster
After this, I think you can run your script without an error.

  0 Comments

Sign in to comment.