Is there any faster way (parfor related)?

1 visualización (últimos 30 días)
Eungyu Park
Eungyu Park el 12 de Mayo de 2020
Respondida: Bjarke Skogstad Larsen el 12 de Mayo de 2020
I want to reduce the computational time of following parfor loop. I think many MATLAB users who use techniques of MCMC, ES, or any Monte-Carlo have similar problems. Please share your thoughts. Many thanks!
A=[]; % cumulation matrix
parfor ii=1:100 % or more than 100
b=some_function(ii); % b is very tall, say it has dimension of 1000000X5 or taller
A=[A b]; % cumulation
end

Respuesta aceptada

Bjarke Skogstad Larsen
Bjarke Skogstad Larsen el 12 de Mayo de 2020
You could speed this up by pre-allocating memory for A if you know the size of b:
A=nan(1000000,5,100); % cumulation matrix
parfor ii=1:100 % or more than 100
A(:,:,ii)=some_function(ii); % b is very tall, say it has dimension of 1000000X5 or taller
end

Más respuestas (0)

Categorías

Más información sobre Parallel Computing en Help Center y File Exchange.

Productos


Versión

R2020a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by