Borrar filtros
Borrar filtros

Speed up triple 'for' loop with parfor

1 visualización (últimos 30 días)
Fotaras Sitof
Fotaras Sitof el 28 de Feb. de 2016
Comentada: Jan el 28 de Feb. de 2016
Dear Matlab users,
I have a 4D dataset of images [360x360x30x20] corresponding to (x,y,z,t) dimensions, with x and y being the pixel coordinates, z the slice and t time. I need to extract the pixel values along the 4th dimension (t) and then use them in further calculations. Currently, I'm using a triple 'for' loop for the extraction and a cell array to store the values. The stored values are then used in further calculations and the results are saved in another cell array B. This loop is rather slow, so I was wondering how to use a 'parfor' loop instead. It seems that I can only replace the innermost 'for' with 'parfor', but I'm not sure if that's the best way to proceed. Any suggestions are greatly appreciated.
for i=1:x
for j=1:y
for k=1:z
A{i,j,k}=squeeze(data(i,j,k,:));
% calculations using the stored values in A
% results stored in cell array B
end
end
end
  1 comentario
Jan
Jan el 28 de Feb. de 2016
What does the profiler tell you about the bottlenecks? Is A preallocated properly?

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by