When trying to run the code below:
outfname = ["path\to\file"];
poolobj = gcp;
addAttachedFiles(poolobj, {'testdata.mat'});
spmd
imgdata = load('testdata.mat');
end
parfor idx = 1:300
idxCopy = idx;
if strlength(string(idx)) == 1
idxCopy = strcat('00', string(idx));
elseif strlength(string(idx)) == 2
idxCopy = strcat('0', string(idx));
end
this_outfname = [outfname, idxCopy, ".jpg"];
join(this_outfname, "");
some_function(this_outfname, imgdata, idx);
end
where 'imgdata' is a struct with each row having data that is unique to it's associated image. That is, every element of the struct is variable. Comments are my understandings of what I'm trying to do.
Having been unable to find a working solution, this is the output that I am getting:
Warning: Files that have already been attached are being ignored. To see which files are attached see the
'AttachedFiles' property of the parallel pool.
ProcessPool with properties:
Connected: true
NumWorkers: 4
Cluster: local
AttachedFiles: path\to\file
AutoAddClientPath: true
IdleTimeout: 30 minutes (23 minutes remaining)
SpmdEnabled: true
Analyzing and transferring files to the workers ...
Error using try_exifwrite (line 15)
An UndefinedFunction error was thrown on the workers for 'imgdata'. This might be because the file containing
'imgdata' is not accessible on the workers. Use addAttachedFiles(pool, files) to specify the required files to be
attached. For more information, see the documentation for 'parallel.Pool/addAttachedFiles'.
Caused by:
Unrecognized function or variable 'imgdata'.
Thank you for any help!