Pass two .mat files into a function withing a paralel loop
5 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi,
I want to pass two .mat files that include some variables into a function that changes over a parallel loop, but I keep getting this error: An UndefinedFunction error was thrown on the workers for 'temp_ui_exp'. This might be because the file containing 'temp_ui_exp' is not accessible on the workers. Use addAttachedFiles(pool, files) to specify the required files to be attached. See the documentation for 'parallel.Pool/addAttachedFiles' for more details.
The code is something like the following:
parpool('AttachedFiles',{'temp_UI.mat','bellman7.mat'});
parfor iter=1:20
[output(iter,1)]=myfunction(varlist);
end
Any help is much appreciated.
0 Commenti
Risposte (1)
Swastik Sarkar
il 29 Nov 2024
I assume that temp_ui_exp is a constant stored in the MAT files attached during the creation of parpool, and the function myfunction utilizes it. Consider declaring a parallel pool constant using code similar to the following:
tempUI = parallel.pool.Constant(@() load('temp_UI.mat'));
And pass tempUI into the function and load it's value like tempUI.Value.temp_ui_exp
Pass tempUI into the function and load its value using tempUI.Value.temp_ui_exp
For more information on parallel pool constants, refer to the following MATLAB documentation:
Hope this helps load variables from MAT files onto the workers.
0 Commenti
Vedere anche
Categorie
Scopri di più su Parallel for-Loops (parfor) in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!