필터 지우기
필터 지우기

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

조회 수: 3 (최근 30일)
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.

채택된 답변

Matt J
Matt J 2015년 6월 29일
편집: Matt J 2015년 6월 29일
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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Parallel Computing Fundamentals에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by