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에서 Parallel for-Loops (parfor)에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!