Azzera filtri
Azzera filtri

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

3 visualizzazioni (ultimi 30 giorni)
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.

Risposta accettata

Matt J
Matt J il 29 Giu 2015
Modificato: Matt J il 29 Giu 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

Più risposte (0)

Categorie

Scopri di più su Parallel Computing Fundamentals in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by