Effacer les filtres
Effacer les filtres

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

3 vues (au cours des 30 derniers jours)
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.

Réponse acceptée

Matt J
Matt J le 29 Juin 2015
Modifié(e) : Matt J le 29 Juin 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

Plus de réponses (0)

Catégories

En savoir plus sur Parallel Computing Fundamentals dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by