Trouble with parfor due to the way of indexing a cell
1 回表示 (過去 30 日間)
古いコメントを表示
I tried to write the constructor for the Class Analysis I defined. One of its property e is a cell and each element of the cell is a instance of another class Ephys. In the constructor, I wrote a nested for-loop to instantiate each element of e. To accelerate, I used parfor for the inner for-loop but the editor reported that the PARFOR Loop cannot run due to the way variable 'a' is used.
I can't figure out the reason why parfor doen't work, because each element of a.e seems to be independently accessed. Any ideas? Or any other ways to accelerate?Thank you so much!
classdef Analysis
properties
e
end
methods
function a = Analysis(path_txt, path_plx, folder_wav)
neurons = Spike.split(path_txt);
songs = Sound.split(folder_wav);
t = Trigger(path_plx);
for m = 1: length(neurons) % nested for loop, layer 1
sp = Spike(neurons{m});
parfor n = 1: length(songs) %layer 2, where I used parfor
so = Sound(songs{n});
a.e{m,n} = Ephys(sp,t,so);
end
end
end
end
end
回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Loops and Conditional Statements についてさらに検索
製品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!