フィルターのクリア

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 Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by