필터 지우기
필터 지우기

Speed up triple 'for' loop with parfor

조회 수: 1 (최근 30일)
Fotaras Sitof
Fotaras Sitof 2016년 2월 28일
댓글: Jan 2016년 2월 28일
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
Jan
Jan 2016년 2월 28일
What does the profiler tell you about the bottlenecks? Is A preallocated properly?

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by