How to modify different part of a same array on the different index of a parfor loop?

1 Ansicht (letzte 30 Tage)
Hello,
I am working on the last version of Matlab (R2015a) and deal with a lot of signals from several sensors. For example, I can have 4000 signals from 20 sensors, and each signal is an array of 512 points. In my work, I calculate the variance on a slippery window of 5 points for each signal and use the result after (the result is an array of the same size than the signal treated). My objective is to realise this calculation of the sensors 1 to 5, in the same time of the one with sensors 6 to 10, 11 to 15 and 16 to 20 using the different cores of my computer. I am discovering the toolbox which permits to deal with pools and the parfor function. There is a lot of conditions to respect, ok, but I don't find the answer at my question:
Can we modify the differents part of a same array in the different index of the loop? For example:
parpool(4)
array = ones(1,512);
limit = floor(length(array/4));
parfor i=1:1:4
array(1+(i-1)*lim:i*lim) = function();
end
I thank you in advance for your help. Best regards.

Akzeptierte Antwort

Matt J
Matt J am 29 Jun. 2015
Bearbeitet: Matt J am 29 Jun. 2015
You need to reshape the data so that the parallel chunks form slicable sections of the array,
array=reshape(array,lim,[]);
parfor i=1:4
array(:,i) = function();
end

Weitere Antworten (0)

Kategorien

Mehr zu Parallel Computing Fundamentals finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by