Filter löschen
Filter löschen

Trouble with parfor due to the way of indexing a cell

1 Ansicht (letzte 30 Tage)
zhehao.nkd
zhehao.nkd am 12 Apr. 2021
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

Antworten (0)

Kategorien

Mehr zu Parallel for-Loops (parfor) finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by