Cell arrays in MATLAB using parfor -


i need parallelize script in matlab. have cell array returning values to. but, matlab not accept way structure parallelization of script.

n_h = 4; n_r = 6; n_s = 20;  p{1:n_h, 1} = zeros(n_s, n_r);  workers = 4;                                % number of cores (workers) parallel computing  multicore = parpool('local', workers);      % open multiple workers (cores) parallel computation   h = 1:1:n_h     r = 1:1:n_r         parfor s = 1:n_s             p{h,1}(s,r) = function ...          end     end end  delete(multicore);                      % delete multiple workers (cores) opened parallel computation 

matlab responds variable p indexed in way incompatible parfor. how should change script?

the easiest way create temporary vector, store parallel results there, , assign values @ once.

for h = 1:1:n_h     r = 1:1:n_r         svec = zeros(n_s, 1);         parfor s = 1:n_s             svec(s) = my_very_parallelizable_func(param1, param2);         end         p{h,1}(:,r) = svec;     end end 

Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -